Use PYENV_BOOTSTRAP_VERSION during python-build if declared

This commit is contained in:
Yamashita, Yuu 2015-12-07 05:10:11 +00:00
parent 20432dda88
commit 2767461235

View file

@ -177,41 +177,50 @@ if [ -z "${PYTHON_BUILD_CACHE_PATH}" ] && [ -d "${PYENV_ROOT}/cache" ]; then
export PYTHON_BUILD_CACHE_PATH="${PYENV_ROOT}/cache" export PYTHON_BUILD_CACHE_PATH="${PYENV_ROOT}/cache"
fi fi
# Default PYENV_VERSION to the friendly Python version. (The if [ -z "${PYENV_BOOTSTRAP_VERSION}" ]; then
# CPython installer requires an existing Python installation to run. An case "${VERSION_NAME}" in
# unsatisfied local .python-version file can cause the installer to [23]"."* )
# fail.) # Default PYENV_VERSION to the friendly Python version. (The
if [[ "${VERSION_NAME}" == [23]"."* ]]; then # CPython installer requires an existing Python installation to run. An
for version in "${VERSION_NAME%-dev}" "${VERSION_NAME%.*}" "${VERSION_NAME%%.*}"; do # unsatisfied local .python-version file can cause the installer to
# Anaconda's `curl` doesn't work on platfrom where `/etc/pki/tls/certs/ca-bundle.crt` isn't available (e.g. Debian) # fail.)
PYENV_VERSION="$(pyenv-whence "python${version}" 2>/dev/null | grep -v conda | tail -n 1 || true)" for version_info in "${VERSION_NAME%-dev}" "${VERSION_NAME%.*}" "${VERSION_NAME%%.*}"; do
if [ -n "${PYENV_VERSION}" ]; then # Anaconda's `curl` doesn't work on platfrom where `/etc/pki/tls/certs/ca-bundle.crt` isn't available (e.g. Debian)
export PYENV_VERSION for version in $(pyenv-whence "python${version_info}" 2>/dev/null || true); do
break if [[ "${version}" != "anaconda"* ]] && [[ "${version}" != "miniconda"* ]]; then
fi PYENV_BOOTSTRAP_VERSION="${version}"
done break 2
fi fi
done
# PyPy/PyPy3 requires existing Python 2.7 to build
if [[ "${VERSION_NAME}" == "pypy-"*"-src" ]] || [[ "${VERSION_NAME}" == "pypy3-"*"-src" ]]; then
if [ -z "$PYENV_RPYTHON_VERSION" ]; then
for version in $(pyenv-versions --bare | sort -r); do
if [[ "$version" == "2.7"* ]]; then
PYENV_RPYTHON_VERSION="$version"
fi
done done
fi ;;
if [ -n "$PYENV_RPYTHON_VERSION" ]; then "pypy-"*"-src" | "pypy3-"*"-src" )
if PYENV_VERSION="$PYENV_RPYTHON_VERSION" pyenv-exec python -c 'import curses' 1>/dev/null 2>&1; then # PyPy/PyPy3 requires existing Python 2.7 to build
export PYENV_VERSION="$PYENV_RPYTHON_VERSION" if [ -n "${PYENV_RPYTHON_VERSION}" ]; then
PYENV_BOOTSTRAP_VERSION="${PYENV_RPYTHON_VERSION}"
else else
echo "pyenv-install: $VERSION_NAME: PyPy requires \`curses' in $PYENV_RPYTHON_VERSION to build from source." >&2 for version in $(pyenv-versions --bare | sort -r); do
if [[ "${version}" == "2.7"* ]]; then
PYENV_BOOTSTRAP_VERSION="$version"
break
fi
done
fi
if [ -n "$PYENV_BOOTSTRAP_VERSION" ]; then
if ! PYENV_VERSION="$PYENV_BOOTSTRAP_VERSION" pyenv-exec python -c 'import curses' 1>/dev/null 2>&1; then
echo "pyenv-install: $VERSION_NAME: PyPy requires \`curses' in $PYENV_BOOTSTRAP_VERSION to build from source." >&2
exit 1
fi
else
echo "pyenv-install: $VERSION_NAME: PyPy requires Python 2.7 to build from source." >&2
exit 1 exit 1
fi fi
else ;;
echo "pyenv-install: $VERSION_NAME: PyPy requires Python 2.5, 2.6 or 2.7 to build from source." >&2 esac
exit 1 fi
fi
if [ -n "${PYENV_BOOTSTRAP_VERSION}" ]; then
export PYENV_VERSION="${PYENV_BOOTSTRAP_VERSION}"
fi fi
# Execute `before_install` hooks. # Execute `before_install` hooks.