Merge pull request #1131 from pyenv/workaround-get-pip-url-py26-py32

Use custom get-pip URL based on the target version
This commit is contained in:
Yamashita, Yuu 2018-03-29 12:19:46 +09:00 committed by GitHub
commit a41d7561d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 1 deletions

View file

@ -2118,11 +2118,28 @@ if [ -z "${EZ_SETUP_URL}" ]; then
fi
if [ -z "${GET_PIP_URL}" ]; then
if [ -n "${PIP_VERSION}" ]; then
{ colorize 1 "WARNING"
echo ": Setting PIP_VERSION=${PIP_VERSION} is no longer supported and may cause failures during the install process."
} 1>&2
GET_PIP_URL="https://raw.githubusercontent.com/pypa/pip/${PIP_VERSION}/contrib/get-pip.py"
# Unset `PIP_VERSION` from environment before invoking `get-pip.py` to deal with "ValueError: invalid truth value" (pypa/pip#4528)
unset PIP_VERSION
else
GET_PIP_URL="https://bootstrap.pypa.io/get-pip.py"
# Use custom get-pip URL based on the target version (#1127)
case "${DEFINITION_PATH##*/}" in
2.6 | 2.6.* )
GET_PIP_URL="https://bootstrap.pypa.io/2.6/get-pip.py"
;;
3.2 | 3.2.* )
GET_PIP_URL="https://bootstrap.pypa.io/3.2/get-pip.py"
;;
3.3 | 3.3.* )
GET_PIP_URL="https://bootstrap.pypa.io/3.3/get-pip.py"
;;
* )
GET_PIP_URL="https://bootstrap.pypa.io/get-pip.py"
;;
esac
fi
fi

View file

@ -92,6 +92,19 @@ resolve_link() {
$(type -p greadlink readlink | head -1) "$1"
}
run_inline_definition_with_name() {
local definition_name="build-definition"
case "$1" in
"--name="* )
local definition_name="${1#--name=}"
shift 1
;;
esac
local definition="${TMP}/${definition_name}"
cat > "$definition"
run python-build "$definition" "${1:-$INSTALL_ROOT}"
}
@test "apply built-in python patch before building" {
cached_tarball "Python-3.6.2"
@ -326,3 +339,43 @@ OUT
assert_success
assert_output "10.4"
}
@test "use the default EZ_SETUP_URL by default" {
run_inline_definition <<OUT
echo "\${EZ_SETUP_URL}"
OUT
assert_output "https://bootstrap.pypa.io/ez_setup.py"
assert_success
}
@test "use the default GET_PIP_URL by default" {
run_inline_definition <<OUT
echo "\${GET_PIP_URL}"
OUT
assert_output "https://bootstrap.pypa.io/get-pip.py"
assert_success
}
@test "use the custom GET_PIP_URL for 2.6 versions" {
run_inline_definition_with_name --name=2.6 <<OUT
echo "\${GET_PIP_URL}"
OUT
assert_output "https://bootstrap.pypa.io/2.6/get-pip.py"
assert_success
}
@test "use the custom GET_PIP_URL for 3.2 versions" {
run_inline_definition_with_name --name=3.2 <<OUT
echo "\${GET_PIP_URL}"
OUT
assert_output "https://bootstrap.pypa.io/3.2/get-pip.py"
assert_success
}
@test "use the custom GET_PIP_URL for 3.3 versions" {
run_inline_definition_with_name --name=3.3 <<OUT
echo "\${GET_PIP_URL}"
OUT
assert_output "https://bootstrap.pypa.io/3.3/get-pip.py"
assert_success
}