python.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. # This script correctly installs Python dependencies
  3. set -eu
  4. HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd -P)"
  5. # shellcheck disable=SC1090
  6. source "${HERE}/lib.sh"
  7. ensure-venv() {
  8. eval "${HERE}/ensure-venv.sh"
  9. }
  10. upgrade-pip() {
  11. # pip versions before 20.1 do not have `pip cache` as a command which is necessary for the CI
  12. pip install --no-cache-dir --upgrade "pip>=20.1"
  13. # The Python version installed via pyenv does not come with wheel pre-installed
  14. # Installing wheel will speed up installation of Python dependencies
  15. require wheel || pip install wheel
  16. }
  17. install-py-dev() {
  18. ensure-venv
  19. upgrade-pip
  20. # It places us within top src dir to be at the same path as setup.py
  21. # This helps when getsentry calls into this script
  22. cd "${HERE}/.."
  23. echo "--> Installing Sentry (for development)"
  24. # In Big Sur, versions of pip before 20.3 require SYSTEM_VERSION_COMPAT set
  25. if query_big_sur && python -c 'from sys import exit; import pip; from pip._vendor.packaging.version import parse; exit(1 if parse(pip.__version__) < parse("20.3") else 0)'; then
  26. SENTRY_LIGHT_BUILD=1 SYSTEM_VERSION_COMPAT=1 pip install -e '.[dev]'
  27. else
  28. # SENTRY_LIGHT_BUILD=1 disables webpacking during setup.py.
  29. # Webpacked assets are only necessary for devserver (which does it lazily anyways)
  30. # and acceptance tests, which webpack automatically if run.
  31. SENTRY_LIGHT_BUILD=1 pip install -e '.[dev]'
  32. fi
  33. }
  34. "$@"