mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Import recent changes from ruby-build 20160130
This commit is contained in:
parent
f2f703d6d9
commit
c8ab429d7b
11 changed files with 195 additions and 145 deletions
|
@ -5,6 +5,7 @@
|
|||
# Usage: pyenv install [-f] [-kvp] <version>
|
||||
# pyenv install [-f] [-kvp] <definition-file>
|
||||
# pyenv install -l|--list
|
||||
# pyenv install --version
|
||||
#
|
||||
# -l/--list List all available versions
|
||||
# -f/--force Install even if the version appears to be installed already
|
||||
|
@ -14,8 +15,9 @@
|
|||
#
|
||||
# -k/--keep Keep source tree in $PYENV_BUILD_ROOT after installation
|
||||
# (defaults to $PYENV_ROOT/sources)
|
||||
# -v/--verbose Verbose mode: print compilation status to stdout
|
||||
# -p/--patch Apply a patch from stdin before building
|
||||
# -v/--verbose Verbose mode: print compilation status to stdout
|
||||
# --version Show version of python-build
|
||||
# -g/--debug Build a debug version
|
||||
#
|
||||
# For detailed information on installing Python versions with
|
||||
|
@ -25,10 +27,6 @@
|
|||
set -e
|
||||
[ -n "$PYENV_DEBUG" ] && set -x
|
||||
|
||||
if [ -z "$PYENV_ROOT" ]; then
|
||||
PYENV_ROOT="${HOME}/.pyenv"
|
||||
fi
|
||||
|
||||
# Add `share/python-build/` directory from each pyenv plugin to the list of
|
||||
# paths where build definitions are looked up.
|
||||
shopt -s nullglob
|
||||
|
@ -40,6 +38,14 @@ shopt -u nullglob
|
|||
|
||||
# Provide pyenv completions
|
||||
if [ "$1" = "--complete" ]; then
|
||||
echo --list
|
||||
echo --force
|
||||
echo --skip-existing
|
||||
echo --keep
|
||||
echo --patch
|
||||
echo --verbose
|
||||
echo --version
|
||||
echo --debug
|
||||
exec python-build --definitions
|
||||
fi
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ set -e
|
|||
|
||||
# Provide pyenv completions
|
||||
if [ "$1" = "--complete" ]; then
|
||||
echo --force
|
||||
exec pyenv versions --bare
|
||||
fi
|
||||
|
||||
|
@ -22,10 +23,6 @@ usage() {
|
|||
[ -z "$1" ] || exit "$1"
|
||||
}
|
||||
|
||||
if [ -z "$PYENV_ROOT" ]; then
|
||||
PYENV_ROOT="${HOME}/.pyenv"
|
||||
fi
|
||||
|
||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
usage 0
|
||||
fi
|
||||
|
|
|
@ -2,17 +2,19 @@
|
|||
#
|
||||
# Usage: python-build [-kvp] <definition> <prefix>
|
||||
# python-build --definitions
|
||||
# python-build --version
|
||||
#
|
||||
# -k/--keep Do not remove source tree after installation
|
||||
# -v/--verbose Verbose mode: print compilation status to stdout
|
||||
# -p/--patch Apply a patch from stdin before building
|
||||
# -v/--verbose Verbose mode: print compilation status to stdout
|
||||
# -4/--ipv4 Resolve names to IPv4 addresses only
|
||||
# -6/--ipv6 Resolve names to IPv6 addresses only
|
||||
# --definitions List all built-in definitions
|
||||
# --version Show version of python-build
|
||||
# -g/--debug Build a debug version
|
||||
#
|
||||
|
||||
PYTHON_BUILD_VERSION="20151028"
|
||||
PYTHON_BUILD_VERSION="20160130"
|
||||
|
||||
OLDIFS="$IFS"
|
||||
|
||||
|
@ -99,6 +101,11 @@ os_information() {
|
|||
fi
|
||||
}
|
||||
|
||||
is_mac() {
|
||||
[ "$(uname -s)" = "Darwin" ] || return 1
|
||||
[ $# -eq 0 ] || [ "$(osx_version)" "$@" ]
|
||||
}
|
||||
|
||||
# 9.1 -> 901
|
||||
# 10.9 -> 1009
|
||||
# 10.10 -> 1010
|
||||
|
@ -262,24 +269,39 @@ compute_md5() {
|
|||
fi
|
||||
}
|
||||
|
||||
has_checksum_support() {
|
||||
local checksum_command="$1"
|
||||
local has_checksum_var="HAS_CHECKSUM_SUPPORT_${checksum_command}"
|
||||
|
||||
if [ -z "${!has_checksum_var+defined}" ]; then
|
||||
printf -v "$has_checksum_var" "$(echo test | "$checksum_command" >/dev/null; echo $?)"
|
||||
fi
|
||||
return "${!has_checksum_var}"
|
||||
}
|
||||
|
||||
verify_checksum() {
|
||||
# If there's no SHA2 support, return success
|
||||
[ -n "$HAS_SHA2_SUPPORT" ] || return 0
|
||||
local checksum_command="compute_sha2"
|
||||
local checksum_command
|
||||
local filename="$1"
|
||||
local expected_checksum="$(echo "$2" | tr [A-Z] [a-z])"
|
||||
|
||||
# If the specified filename doesn't exist, return success
|
||||
local filename="$1"
|
||||
[ -e "$filename" ] || return 0
|
||||
|
||||
# If there's no expected checksum, return success
|
||||
local expected_checksum=`echo "$2" | tr [A-Z] [a-z]`
|
||||
[ -n "$expected_checksum" ] || return 0
|
||||
case "${#expected_checksum}" in
|
||||
0) return 0 ;; # empty checksum; return success
|
||||
32) checksum_command="compute_md5" ;;
|
||||
64) checksum_command="compute_sha2" ;;
|
||||
*)
|
||||
{ echo
|
||||
echo "unexpected checksum length: ${#expected_checksum} (${expected_checksum})"
|
||||
echo "expected 0 (no checksum), 32 (MD5), or 64 (SHA2-256)"
|
||||
echo
|
||||
} >&4
|
||||
return 1 ;;
|
||||
esac
|
||||
|
||||
# If the checksum length is 32 chars, assume MD5, otherwise SHA2
|
||||
if [ "${#expected_checksum}" -eq 32 ]; then
|
||||
[ -n "$HAS_MD5_SUPPORT" ] || return 0
|
||||
checksum_command="compute_md5"
|
||||
fi
|
||||
# If chosen provided checksum algorithm isn't supported, return success
|
||||
has_checksum_support "$checksum_command" || return 0
|
||||
|
||||
# If the computed checksum is empty, return failure
|
||||
local computed_checksum=`echo "$($checksum_command < "$filename")" | tr [A-Z] [a-z]`
|
||||
|
@ -350,18 +372,19 @@ fetch_tarball() {
|
|||
package_url="${package_url%%#*}"
|
||||
|
||||
if [ -n "$PYTHON_BUILD_MIRROR_URL" ]; then
|
||||
mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum"
|
||||
if [[ -z "$PYTHON_BUILD_DEFAULT_MIRROR" || $package_url != */www.python.org/* ]]; then
|
||||
mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
local tar_args="xzf"
|
||||
local package_filename="${package_name}.tar.gz"
|
||||
|
||||
if [ "$package_url" != "${package_url%tgz}" ]; then
|
||||
package_filename="${package_filename%tar.gz}tgz"
|
||||
fi
|
||||
|
||||
if [ "$package_url" != "${package_url%bz2}" ]; then
|
||||
if ! type -p bzip2 >/dev/null; then
|
||||
echo "warning: bzip2 not found; consider installing \`bzip2\` package" >&4
|
||||
fi
|
||||
package_filename="${package_filename%.gz}.bz2"
|
||||
tar_args="${tar_args/z/j}"
|
||||
fi
|
||||
|
@ -389,19 +412,6 @@ fetch_tarball() {
|
|||
} >&4 2>&1
|
||||
}
|
||||
|
||||
fetch_nightly_tarball() {
|
||||
local package_name="$1"
|
||||
local package_url="$2"
|
||||
local package_pattern="$3"
|
||||
fetch_tarball "$1" "$2"
|
||||
if [ ! -e "${package_name}" ]; then
|
||||
local nightly_package_name="$(echo ${package_pattern})"
|
||||
if [ -e "${nightly_package_name}" ]; then
|
||||
ln -fs "${nightly_package_name}" "${package_name}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
reuse_existing_tarball() {
|
||||
local package_filename="$1"
|
||||
local checksum="$2"
|
||||
|
@ -683,7 +693,7 @@ build_package_standard() {
|
|||
( if [ "${CFLAGS+defined}" ] || [ "${!PACKAGE_CFLAGS+defined}" ]; then
|
||||
export CFLAGS="$CFLAGS ${!PACKAGE_CFLAGS}"
|
||||
fi
|
||||
if [ -z "$CC" ] && [ "$(uname -s)" = "Darwin" ] && [ "$(osx_version)" -ge 1010 ]; then
|
||||
if [ -z "$CC" ] && is_mac -ge 1010; then
|
||||
export CC=clang
|
||||
fi
|
||||
${!PACKAGE_CONFIGURE:-./configure} --prefix="${!PACKAGE_PREFIX_PATH:-$PREFIX_PATH}" \
|
||||
|
@ -718,9 +728,7 @@ build_package_ree_installer() {
|
|||
build_package_auto_tcltk
|
||||
|
||||
local options=""
|
||||
if [[ "Darwin" = "$(uname)" ]]; then
|
||||
options="--no-tcmalloc"
|
||||
fi
|
||||
is_mac && options="--no-tcmalloc"
|
||||
|
||||
local option
|
||||
for option in $RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[@]}; do
|
||||
|
@ -742,7 +750,20 @@ build_package_rbx() {
|
|||
mkdir -p vendor
|
||||
ln -s "$RUBY_BUILD_CACHE_PATH" vendor/prebuilt
|
||||
fi
|
||||
RUBYOPT="-rubygems $RUBYOPT" ./configure --prefix="$PREFIX_PATH" $RUBY_CONFIGURE_OPTS "${RUBY_CONFIGURE_OPTS_ARRAY[@]}"
|
||||
|
||||
local opt
|
||||
local -a configure_opts
|
||||
for opt in "${RUBY_CONFIGURE_OPTS_ARRAY[@]}"; do
|
||||
if [[ $opt == --with-openssl-dir=* ]]; then
|
||||
local openssl_dir="${opt#*=}"
|
||||
configure_opts[${#configure_opts[@]}]="--with-lib-dir=${openssl_dir}/lib"
|
||||
configure_opts[${#configure_opts[@]}]="--with-include-dir=${openssl_dir}/include"
|
||||
else
|
||||
configure_opts[${#configure_opts[@]}]="$opt"
|
||||
fi
|
||||
done
|
||||
|
||||
RUBYOPT="-rubygems $RUBYOPT" ./configure --prefix="$PREFIX_PATH" $RUBY_CONFIGURE_OPTS "${configure_opts[@]}"
|
||||
rake install
|
||||
fix_rbx_gem_binstubs "$PREFIX_PATH"
|
||||
fix_rbx_irb "$PREFIX_PATH"
|
||||
|
@ -804,29 +825,10 @@ build_package_jruby() {
|
|||
fix_jruby_shebangs
|
||||
}
|
||||
|
||||
graal_architecture() {
|
||||
if [ "$(uname -m)" != "x86_64" ]; then
|
||||
echo "no nightly builds available" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$(uname -s)" in
|
||||
"Darwin") echo "macosx-x86_64";;
|
||||
"Linux") echo "linux-x86_64";;
|
||||
*)
|
||||
echo "no nightly builds available" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_jruby_launcher() {
|
||||
# If this version of JRuby has been modified for Graal, don't overwrite the
|
||||
# launcher scripts
|
||||
if ! grep -q graalvm "${PREFIX_PATH}/bin/jruby"; then
|
||||
cd "${PREFIX_PATH}/bin"
|
||||
{ ./ruby gem install jruby-launcher
|
||||
} >&4 2>&1
|
||||
fi
|
||||
cd "${PREFIX_PATH}/bin"
|
||||
{ ./ruby gem install jruby-launcher
|
||||
} >&4 2>&1
|
||||
}
|
||||
|
||||
fix_jruby_shebangs() {
|
||||
|
@ -1065,7 +1067,7 @@ require_gcc() {
|
|||
echo "and try again."
|
||||
echo
|
||||
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
if is_mac; then
|
||||
colorize 1 "DETAILS"
|
||||
echo ": Apple no longer includes the official GCC compiler with Xcode"
|
||||
echo "as of version 4.2. Instead, the \`gcc\` executable is a symlink to"
|
||||
|
@ -1100,7 +1102,7 @@ require_gcc() {
|
|||
fi
|
||||
|
||||
export CC="$gcc"
|
||||
if [ "$(uname -s)" = "Darwin" ] && [ "$(osx_version)" -ge 1010 ]; then
|
||||
if is_mac -ge 1010; then
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.9
|
||||
fi
|
||||
}
|
||||
|
@ -1157,7 +1159,7 @@ verify_gcc() {
|
|||
|
||||
require_llvm() {
|
||||
local llvm_version="$1"
|
||||
if [ "$(uname -s)" = "Darwin" ] && [ "$(osx_version)" -ge 1010 ]; then
|
||||
if is_mac -ge 1010; then
|
||||
if [[ "$PYTHON_CONFIGURE_OPTS" != *--llvm-* ]]; then
|
||||
case "$llvm_version" in
|
||||
3.2 )
|
||||
|
@ -1274,7 +1276,7 @@ use_homebrew_yaml() {
|
|||
has_broken_mac_readline() {
|
||||
# Mac OS X 10.4 has broken readline.
|
||||
# https://github.com/yyuu/pyenv/issues/23
|
||||
[ "$(uname -s)" = "Darwin" ] &&
|
||||
is_mac &&
|
||||
! configured_with_package_dir "python" "readline/rlconf.h" &&
|
||||
! use_homebrew_readline
|
||||
}
|
||||
|
@ -1292,7 +1294,7 @@ use_homebrew_readline() {
|
|||
}
|
||||
|
||||
has_broken_mac_openssl() {
|
||||
[ "$(uname -s)" = "Darwin" ] &&
|
||||
is_mac &&
|
||||
[[ "$(/usr/bin/openssl version 2>/dev/null || true)" = "OpenSSL 0.9.8"?* ]] &&
|
||||
! use_homebrew_openssl
|
||||
}
|
||||
|
@ -1366,7 +1368,7 @@ build_package_ldflags_dirs() {
|
|||
}
|
||||
|
||||
build_package_auto_tcltk() {
|
||||
if [ "Darwin" = "$(uname -s)" ] && [ ! -d /usr/include/X11 ]; then
|
||||
if is_mac && [ ! -d /usr/include/X11 ]; then
|
||||
if [ -d /opt/X11/include ]; then
|
||||
if [[ "$CPPFLAGS" != *-I/opt/X11/include* ]]; then
|
||||
export CPPFLAGS="-I/opt/X11/include $CPPFLAGS"
|
||||
|
@ -1788,27 +1790,16 @@ fi
|
|||
|
||||
if [ -z "$PYTHON_BUILD_MIRROR_URL" ]; then
|
||||
PYTHON_BUILD_MIRROR_URL="https://yyuu.github.io/pythons"
|
||||
PYTHON_BUILD_DEFAULT_MIRROR=1
|
||||
else
|
||||
PYTHON_BUILD_MIRROR_URL="${PYTHON_BUILD_MIRROR_URL%/}"
|
||||
PYTHON_BUILD_DEFAULT_MIRROR=
|
||||
fi
|
||||
|
||||
if [ -n "$PYTHON_BUILD_SKIP_MIRROR" ]; then
|
||||
if [ -n "$PYTHON_BUILD_SKIP_MIRROR" ] || ! has_checksum_support compute_sha2; then
|
||||
unset PYTHON_BUILD_MIRROR_URL
|
||||
fi
|
||||
|
||||
if echo test | compute_sha2 >/dev/null; then
|
||||
HAS_SHA2_SUPPORT=1
|
||||
else
|
||||
unset HAS_SHA2_SUPPORT
|
||||
unset PYTHON_BUILD_MIRROR_URL
|
||||
fi
|
||||
|
||||
if echo test | compute_md5 >/dev/null; then
|
||||
HAS_MD5_SUPPORT=1
|
||||
else
|
||||
unset HAS_MD5_SUPPORT
|
||||
fi
|
||||
|
||||
# Add an option to build a debug version of Python (#11)
|
||||
if [ -n "$DEBUG" ]; then
|
||||
package_option python configure --with-pydebug
|
||||
|
@ -1820,7 +1811,7 @@ package_option python configure --libdir="${PREFIX_PATH}/lib"
|
|||
# python-build: Set `RPATH` if `--enable-shared` was given (#65, #66, #82)
|
||||
if [[ "$CONFIGURE_OPTS" == *"--enable-shared"* ]] || [[ "$PYTHON_CONFIGURE_OPTS" == *"--enable-shared"* ]]; then
|
||||
# The ld on Darwin embeds the full paths to each dylib by default
|
||||
if [[ "$LDFLAGS" != *"-rpath="* ]] && [[ "Darwin" != "$(uname -s)" ]]; then
|
||||
if [[ "$LDFLAGS" != *"-rpath="* ]] && ! is_mac; then
|
||||
export LDFLAGS="-Wl,-rpath=${PREFIX_PATH}/lib ${LDFLAGS}"
|
||||
fi
|
||||
fi
|
||||
|
@ -1832,7 +1823,7 @@ fi
|
|||
|
||||
# Add support for framework installation (`--enable-framework`) of CPython (#55, #99)
|
||||
if [[ "$PYTHON_CONFIGURE_OPTS" == *"--enable-framework"* ]]; then
|
||||
if [[ "Darwin" != "$(uname -s)" ]]; then
|
||||
if ! is_mac; then
|
||||
echo "python-build: framework installation is not supported." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
@ -1852,7 +1843,7 @@ fi
|
|||
|
||||
# Build against universal SDK (#219, #220)
|
||||
if [[ "$PYTHON_CONFIGURE_OPTS" == *"--enable-universalsdk"* ]]; then
|
||||
if [[ "Darwin" != "$(uname -s)" ]]; then
|
||||
if ! is_mac; then
|
||||
echo "python-build: universal installation is not supported." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
@ -1885,7 +1876,7 @@ if [ -n "${PIP_VERSION}" ]; then
|
|||
fi
|
||||
|
||||
# Set MACOSX_DEPLOYMENT_TARGET from the product version of OS X (#219, #220)
|
||||
if [[ "Darwin" == "$(uname -s)" ]]; then
|
||||
if is_mac; then
|
||||
if [ -z "${MACOSX_DEPLOYMENT_TARGET}" ]; then
|
||||
MACOS_VERSION="$(sw_vers -productVersion 2>/dev/null || true)"
|
||||
MACOS_VERSION_ARRAY=(${MACOS_VERSION//\./ })
|
||||
|
|
|
@ -10,30 +10,28 @@ setup() {
|
|||
|
||||
|
||||
@test "packages are saved to download cache" {
|
||||
stub shasum true
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
|
||||
assert_success
|
||||
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "cached package without checksum" {
|
||||
stub shasum true
|
||||
stub curl
|
||||
|
||||
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_CACHE_PATH"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
|
||||
assert_success
|
||||
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,9 +42,10 @@ setup() {
|
|||
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_CACHE_PATH"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
[ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -64,10 +63,11 @@ setup() {
|
|||
touch "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
[ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
diff -q "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz"
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
assert diff -q "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz"
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -75,16 +75,15 @@ setup() {
|
|||
|
||||
|
||||
@test "nonexistent cache directory is ignored" {
|
||||
stub shasum true
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
export PYTHON_BUILD_CACHE_PATH="${TMP}/nonexistent"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
[ ! -d "$PYTHON_BUILD_CACHE_PATH" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
refute [ -d "$PYTHON_BUILD_CACHE_PATH" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
|
|
@ -6,15 +6,14 @@ export PYTHON_BUILD_CACHE_PATH=
|
|||
|
||||
|
||||
@test "package URL without checksum" {
|
||||
stub shasum true
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,8 +22,9 @@ export PYTHON_BUILD_CACHE_PATH=
|
|||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -36,8 +36,9 @@ export PYTHON_BUILD_CACHE_PATH=
|
|||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-invalid-checksum
|
||||
[ "$status" -eq 1 ]
|
||||
[ ! -f "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_failure
|
||||
refute [ -f "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -49,8 +50,9 @@ export PYTHON_BUILD_CACHE_PATH=
|
|||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -62,8 +64,9 @@ export PYTHON_BUILD_CACHE_PATH=
|
|||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-md5-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub md5
|
||||
|
@ -75,8 +78,9 @@ export PYTHON_BUILD_CACHE_PATH=
|
|||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-md5-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub md5
|
||||
|
@ -88,8 +92,9 @@ export PYTHON_BUILD_CACHE_PATH=
|
|||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 1 ]
|
||||
[ ! -f "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_failure
|
||||
refute [ -f "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -111,7 +116,7 @@ install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.g
|
|||
DEF
|
||||
|
||||
assert_success
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub shasum
|
||||
}
|
||||
|
@ -133,7 +138,20 @@ install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.g
|
|||
DEF
|
||||
|
||||
assert_success
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
@test "package URL with checksum of unexpected length" {
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
run_inline_definition <<DEF
|
||||
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#checksum_of_unexpected_length" copy
|
||||
DEF
|
||||
|
||||
assert_failure
|
||||
refute [ -f "${INSTALL_ROOT}/bin/package" ]
|
||||
assert_output_contains "unexpected checksum length: 29 (checksum_of_unexpected_length)"
|
||||
assert_output_contains "expected 0 (no checksum), 32 (MD5), or 64 (SHA2-256)"
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ NUM_DEFINITIONS="$(find "$BATS_TEST_DIRNAME"/../share/python-build -maxdepth 1 -
|
|||
|
||||
@test "custom PYTHON_BUILD_ROOT: nonexistent" {
|
||||
export PYTHON_BUILD_ROOT="$TMP"
|
||||
assert [ ! -e "${PYTHON_BUILD_ROOT}/share/python-build" ]
|
||||
refute [ -e "${PYTHON_BUILD_ROOT}/share/python-build" ]
|
||||
run python-build --definitions
|
||||
assert_success ""
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#invalid" copy
|
||||
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#invalid_64_character_checksum_0000000000000000000000000000000000" copy
|
||||
|
|
|
@ -52,5 +52,5 @@ rehashed
|
|||
after.
|
||||
OUT
|
||||
|
||||
assert [ ! -d "${PYENV_ROOT}/versions/3.2.1" ]
|
||||
refute [ -d "${PYENV_ROOT}/versions/3.2.1" ]
|
||||
}
|
||||
|
|
|
@ -12,8 +12,9 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
|
||||
install_fixture definitions/without-checksum
|
||||
echo "$output" >&2
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -25,8 +26,9 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -42,8 +44,9 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
"-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -59,8 +62,9 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
"-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -78,8 +82,9 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
|
||||
install_fixture definitions/with-checksum
|
||||
echo "$output" >&2
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
@ -95,8 +100,28 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
"-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "package URL with ruby-lang CDN with default mirror URL will bypasses mirror" {
|
||||
export PYTHON_BUILD_MIRROR_URL=
|
||||
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
|
||||
stub shasum true "echo $checksum"
|
||||
stub curl "-q -o * -*S* https://www.python.org/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
run_inline_definition <<DEF
|
||||
install_package "package-1.0.0" "https://www.python.org/packages/package-1.0.0.tar.gz#ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" copy
|
||||
DEF
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
|
|
|
@ -141,6 +141,14 @@ OUT
|
|||
run pyenv-install --complete
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
--list
|
||||
--force
|
||||
--skip-existing
|
||||
--keep
|
||||
--patch
|
||||
--verbose
|
||||
--version
|
||||
--debug
|
||||
|
||||
${PYENV_ROOT}/plugins/bar/share/python-build
|
||||
${PYENV_ROOT}/plugins/foo/share/python-build
|
||||
|
|
|
@ -71,6 +71,12 @@ assert() {
|
|||
fi
|
||||
}
|
||||
|
||||
refute() {
|
||||
if "$@"; then
|
||||
flunk "expected to fail: $@"
|
||||
fi
|
||||
}
|
||||
|
||||
flunk() {
|
||||
{ if [ "$#" -eq 0 ]; then cat -
|
||||
else echo "$@"
|
||||
|
|
Loading…
Reference in a new issue