|
@@ -5,7 +5,10 @@
|
|
# - This script assumes you're calling from the top directory of the repository
|
|
# - This script assumes you're calling from the top directory of the repository
|
|
set -eu
|
|
set -eu
|
|
|
|
|
|
-HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd -P)"
|
|
|
|
|
|
+HERE="$(
|
|
|
|
+ cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
|
|
+ pwd -P
|
|
|
|
+)"
|
|
# shellcheck disable=SC1090
|
|
# shellcheck disable=SC1090
|
|
source "${HERE}/lib.sh"
|
|
source "${HERE}/lib.sh"
|
|
|
|
|
|
@@ -13,18 +16,19 @@ get_shell_startup_script() {
|
|
local _startup_script=''
|
|
local _startup_script=''
|
|
if [[ -n "$SHELL" ]]; then
|
|
if [[ -n "$SHELL" ]]; then
|
|
case "$SHELL" in
|
|
case "$SHELL" in
|
|
- */bash)
|
|
|
|
- _startup_script="${HOME}/.bash_profile"
|
|
|
|
- ;;
|
|
|
|
- */zsh)
|
|
|
|
- _startup_script="${HOME}/.zshrc"
|
|
|
|
- ;;
|
|
|
|
- */fish)
|
|
|
|
- _startup_script="${HOME}/.config/fish/config.fish"
|
|
|
|
- ;;
|
|
|
|
- *)
|
|
|
|
- echo "$SHELL is currently not supported."
|
|
|
|
- exit 1
|
|
|
|
|
|
+ */bash)
|
|
|
|
+ _startup_script="${HOME}/.bash_profile"
|
|
|
|
+ ;;
|
|
|
|
+ */zsh)
|
|
|
|
+ _startup_script="${HOME}/.zshrc"
|
|
|
|
+ ;;
|
|
|
|
+ */fish)
|
|
|
|
+ _startup_script="${HOME}/.config/fish/config.fish"
|
|
|
|
+ ;;
|
|
|
|
+ *)
|
|
|
|
+ echo "$SHELL is currently not supported."
|
|
|
|
+ exit 1
|
|
|
|
+ ;;
|
|
esac
|
|
esac
|
|
else
|
|
else
|
|
echo "The environment variable \$SHELL needs to be defined."
|
|
echo "The environment variable \$SHELL needs to be defined."
|
|
@@ -36,16 +40,17 @@ get_shell_startup_script() {
|
|
_append_to_startup_script() {
|
|
_append_to_startup_script() {
|
|
if [[ -n "$SHELL" ]]; then
|
|
if [[ -n "$SHELL" ]]; then
|
|
case "$SHELL" in
|
|
case "$SHELL" in
|
|
- */bash)
|
|
|
|
- # shellcheck disable=SC2016
|
|
|
|
- echo -e '\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> "${1}"
|
|
|
|
- ;;
|
|
|
|
- */zsh)
|
|
|
|
- # shellcheck disable=SC2016
|
|
|
|
- echo -e '\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> "${1}"
|
|
|
|
- ;;
|
|
|
|
- */fish)
|
|
|
|
- echo -e '\n\n# pyenv init\nif command -v pyenv 1>/dev/null 2>&1\n pyenv init - | source\nend' >> "$1"
|
|
|
|
|
|
+ */bash)
|
|
|
|
+ # shellcheck disable=SC2016
|
|
|
|
+ echo -e '\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >>"${1}"
|
|
|
|
+ ;;
|
|
|
|
+ */zsh)
|
|
|
|
+ # shellcheck disable=SC2016
|
|
|
|
+ echo -e '\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >>"${1}"
|
|
|
|
+ ;;
|
|
|
|
+ */fish)
|
|
|
|
+ echo -e '\n\n# pyenv init\nif command -v pyenv 1>/dev/null 2>&1\n pyenv init - | source\nend' >>"$1"
|
|
|
|
+ ;;
|
|
esac
|
|
esac
|
|
|
|
|
|
echo "--> Tail of ${1}"
|
|
echo "--> Tail of ${1}"
|
|
@@ -71,23 +76,26 @@ install_pyenv() {
|
|
echo "Installing Python (if missing) via pyenv"
|
|
echo "Installing Python (if missing) via pyenv"
|
|
local pyenv_version
|
|
local pyenv_version
|
|
pyenv_version=$(pyenv -v | awk '{print $2}')
|
|
pyenv_version=$(pyenv -v | awk '{print $2}')
|
|
- python_version=$(xargs -n1 < .python-version)
|
|
|
|
|
|
+ python_version=$(xargs -n1 <.python-version)
|
|
|
|
+ # NOTE: Older pyenv does not have access to the latest Python we require
|
|
|
|
+ if [[ "$pyenv_version" < 1.2.26 ]]; then
|
|
|
|
+ echo >&2 "!!! Your pyenv is old and does not know how to find the Python we require." \
|
|
|
|
+ "Run the following (this is slow) and try again."
|
|
|
|
+ echo >&2 "brew update && brew upgrade pyenv"
|
|
|
|
+ exit 1
|
|
|
|
+ fi
|
|
|
|
|
|
|
|
+ # We need to patch the source code on Big Sur before building Python
|
|
|
|
+ # We can remove this once we upgrade to newer versions of Python
|
|
if query_big_sur; then
|
|
if query_big_sur; then
|
|
- local flag
|
|
|
|
- # NOTE: pyenv 1.2.22 or greater does not require using LDFLAGS
|
|
|
|
- # https://github.com/pyenv/pyenv/pull/1711
|
|
|
|
- if [[ "$pyenv_version" < 1.2.22 ]]; then
|
|
|
|
- flag="-L$(xcrun --show-sdk-path)/usr/lib ${LDFLAGS}"
|
|
|
|
- fi
|
|
|
|
# cat is used since pyenv would finish to soon when the Python version is already installed
|
|
# cat is used since pyenv would finish to soon when the Python version is already installed
|
|
- curl -sSL https://github.com/python/cpython/commit/8ea6353.patch | cat | \
|
|
|
|
- LDFLAGS="$flag" pyenv install --skip-existing --patch "$python_version"
|
|
|
|
|
|
+ curl -sSL https://github.com/python/cpython/commit/8ea6353.patch | cat |
|
|
|
|
+ pyenv install --skip-existing --patch "$python_version"
|
|
else
|
|
else
|
|
pyenv install --skip-existing "$python_version"
|
|
pyenv install --skip-existing "$python_version"
|
|
fi
|
|
fi
|
|
else
|
|
else
|
|
- echo "!!! pyenv not found, try running bootstrap script again or run \`brew bundle\` in the sentry repo"
|
|
|
|
|
|
+ echo >&2 "!!! pyenv not found, try running bootstrap script again or run \`brew bundle\` in the sentry repo"
|
|
exit 1
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|
|
}
|
|
@@ -104,7 +112,7 @@ setup_pyenv() {
|
|
echo "Activating pyenv and validating Python version"
|
|
echo "Activating pyenv and validating Python version"
|
|
eval "$(pyenv init -)"
|
|
eval "$(pyenv init -)"
|
|
python_version=$(python -V | sed s/Python\ //g)
|
|
python_version=$(python -V | sed s/Python\ //g)
|
|
- [[ $python_version == $(cat .python-version) ]] || \
|
|
|
|
|
|
+ [[ $python_version == $(cat .python-version) ]] ||
|
|
(echo "Wrong Python version: $python_version. Please report in #discuss-dev-tooling" && exit 1)
|
|
(echo "Wrong Python version: $python_version. Please report in #discuss-dev-tooling" && exit 1)
|
|
}
|
|
}
|
|
|
|
|