ensure-venv.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. HERE="$(
  3. cd "$(dirname "${BASH_SOURCE[0]}")" || exit
  4. pwd -P
  5. )"
  6. # shellcheck disable=SC1090
  7. source "${HERE}/lib.sh"
  8. # optionally opt out of virtualenv creation
  9. # WARNING: this will be removed (most likely renamed) soon!
  10. if [[ "$SENTRY_NO_VIRTUALENV_CREATION" == "1" ]]; then
  11. exit 0
  12. fi
  13. die() {
  14. cat <<EOF
  15. $@
  16. EOF
  17. exit 1
  18. }
  19. if [[ -n "$VIRTUAL_ENV" ]]; then
  20. # Let's make sure they know that they're not using a different version by mistake
  21. query-valid-python-version || exit 1
  22. else
  23. if [[ ! -f "${venv_name}/bin/activate" ]]; then
  24. die "You don't seem to have a virtualenv. Please create one by running: source ./scripts/bootstrap-py3-venv"
  25. fi
  26. die "You have a virtualenv, but it doesn't seem to be activated. Please run: source ${venv_name}/bin/activate"
  27. fi
  28. if [ -L "${venv_name}/bin/python3" ] && [ ! -e "${venv_name}/bin/python3" ]; then
  29. die "Your symlink ${venv_name}/bin/python3 seems to be pointing to a non-existing Python binary. Try: rm -rf ${venv_name} && direnv allow"
  30. fi
  31. # Somehow it does not succeed unless I exit with 0
  32. exit 0