| 1 | #!bash |
| 2 | # |
| 3 | # Copyright 2019 - 2025 |
| 4 | # Andr\xe9 Malo or his licensors, as applicable |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | |
| 18 | set -e |
| 19 | |
| 20 | # Parse arguments |
| 21 | want_python= |
| 22 | want_upgrade= |
| 23 | # while getopts "pu" opt; do |
| 24 | while getopts "u" opt; do |
| 25 | case "${opt}" in |
| 26 | # p) want_python=1 ;; |
| 27 | u) want_upgrade=1 ;; |
| 28 | *) die "Unknown option -${opt}" ;; |
| 29 | esac |
| 30 | done |
| 31 | shift "$((OPTIND - 1))" |
| 32 | |
| 33 | dir="${1}" |
| 34 | shift |
| 35 | |
| 36 | [ -n "${VIRTUAL_ENV}" ] |
| 37 | [ -n "${dir}" ] |
| 38 | |
| 39 | source "${VIRTUAL_ENV}/bin/activate" |
| 40 | |
| 41 | # if [ "${want_python}" = "1" ]; then |
| 42 | # ( |
| 43 | # set -e |
| 44 | # |
| 45 | # cd "${VIRTUAL_ENV}" |
| 46 | # mkvirtualenv --clear --python \ |
| 47 | # "$(pyv="$(python -c 'import sys; print("python" + ".".join(map(str, sys.version_info[:2])))')"; \ |
| 48 | # deactivate; which "${pyv}")" . |
| 49 | # ) || exit $? |
| 50 | # fi |
| 51 | |
| 52 | cd "${dir}" |
| 53 | pip freeze | grep -v '^-e ' | while read file; do |
| 54 | pip uninstall -y "${file}" |
| 55 | done |
| 56 | |
| 57 | upgrade=() |
| 58 | if [ "${want_upgrade}" = "1" ]; then |
| 59 | upgrade=( "-U" ) |
| 60 | fi |
| 61 | pip install "${upgrade[@]}" setuptools pip |
| 62 | pip install "${upgrade[@]}" -r development.txt |