mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-11 13:03:46 -05:00
Import recent changess from ruby-build v20140408
This commit is contained in:
@@ -6,16 +6,17 @@
|
||||
# pyenv install [-f] [-kvp] <definition-file>
|
||||
# pyenv install -l|--list
|
||||
#
|
||||
# -l/--list List all available versions
|
||||
# -f/--force Install even if the version appears to be installed already
|
||||
# -l/--list List all available versions
|
||||
# -f/--force Install even if the version appears to be installed already
|
||||
# -s/--skip-existing Skip if the version appears to be installed already
|
||||
#
|
||||
# python-build options:
|
||||
#
|
||||
# -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
|
||||
# -g/--debug Build a debug version
|
||||
# -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
|
||||
# -g/--debug Build a debug version
|
||||
#
|
||||
# For detailed information on installing Python versions with
|
||||
# python-build, including a list of environment variables for adjusting
|
||||
@@ -52,6 +53,7 @@ indent() {
|
||||
}
|
||||
|
||||
unset FORCE
|
||||
unset SKIP_EXISTING
|
||||
unset KEEP
|
||||
unset VERBOSE
|
||||
unset HAS_PATCH
|
||||
@@ -71,6 +73,9 @@ for option in "${OPTIONS[@]}"; do
|
||||
"f" | "force" )
|
||||
FORCE=true
|
||||
;;
|
||||
"s" | "skip-existing" )
|
||||
SKIP_EXISTING=true
|
||||
;;
|
||||
"k" | "keep" )
|
||||
[ -n "${PYENV_BUILD_ROOT}" ] || PYENV_BUILD_ROOT="${PYENV_ROOT}/sources"
|
||||
;;
|
||||
@@ -134,14 +139,21 @@ PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}"
|
||||
|
||||
# If the installation prefix exists, prompt for confirmation unless
|
||||
# the --force option was specified.
|
||||
if [ -z "$FORCE" ] && [ -d "${PREFIX}/bin" ]; then
|
||||
echo "pyenv: $PREFIX already exists" >&2
|
||||
read -p "continue with installation? (y/N) "
|
||||
if [ -d "${PREFIX}/bin" ]; then
|
||||
if [ -z "$FORCE" ] && [ -z "$SKIP_EXISTING" ]; then
|
||||
echo "pyenv: $PREFIX already exists" >&2
|
||||
read -p "continue with installation? (y/N) "
|
||||
|
||||
case "$REPLY" in
|
||||
y* | Y* ) ;;
|
||||
* ) exit 1 ;;
|
||||
esac
|
||||
case "$REPLY" in
|
||||
y* | Y* ) ;;
|
||||
* ) exit 1 ;;
|
||||
esac
|
||||
elif [ -n "$SKIP_EXISTING" ]; then
|
||||
# Since we know the python version is already installed, and are opting to
|
||||
# not force installation of existing versions, we just `exit 0` here to
|
||||
# leave things happy
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# If PYENV_BUILD_ROOT is set, always pass keep options to python-build.
|
||||
@@ -158,7 +170,7 @@ fi
|
||||
|
||||
# Default PYENV_VERSION to the friendly Python version. (The
|
||||
# CPython installer requires an existing Python installation to run. An
|
||||
# unsatisfied local python version can cause the installer to
|
||||
# unsatisfied local .python-version file can cause the installer to
|
||||
# fail.)
|
||||
if [[ "${VERSION_NAME}" == [23]"."* ]]; then
|
||||
for version in "${VERSION_NAME%-dev}" "${VERSION_NAME%.*}" "${VERSION_NAME%%.*}"; do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PYTHON_BUILD_VERSION="20140225"
|
||||
PYTHON_BUILD_VERSION="20140408"
|
||||
|
||||
set -E
|
||||
exec 3<&2 # preserve original stderr at fd 3
|
||||
@@ -245,7 +245,7 @@ http_head_curl() {
|
||||
}
|
||||
|
||||
http_get_curl() {
|
||||
curl -C - -o "${2:--}" -qsSLf "$1"
|
||||
curl -q -o "${2:--}" -sSLf "$1"
|
||||
}
|
||||
|
||||
http_head_wget() {
|
||||
@@ -253,7 +253,7 @@ http_head_wget() {
|
||||
}
|
||||
|
||||
http_get_wget() {
|
||||
wget -nv -c -O "${2:--}" "$1"
|
||||
wget -nv -O "${2:--}" "$1"
|
||||
}
|
||||
|
||||
fetch_tarball() {
|
||||
@@ -283,7 +283,7 @@ fetch_tarball() {
|
||||
tar_args="${tar_args/z/j}"
|
||||
fi
|
||||
|
||||
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
|
||||
if ! reuse_existing_tarball "$package_filename" "$checksum"; then
|
||||
echo "Downloading ${package_filename}..." >&2
|
||||
http head "$mirror_url" &&
|
||||
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
|
||||
@@ -300,13 +300,19 @@ fetch_tarball() {
|
||||
} >&4 2>&1
|
||||
}
|
||||
|
||||
symlink_tarball_from_cache() {
|
||||
[ -n "$PYTHON_BUILD_CACHE_PATH" ] || return 1
|
||||
|
||||
reuse_existing_tarball() {
|
||||
local package_filename="$1"
|
||||
local cached_package_filename="${PYTHON_BUILD_CACHE_PATH}/$package_filename"
|
||||
local checksum="$2"
|
||||
|
||||
# Reuse existing file in build location
|
||||
if [ -e "$package_filename" ] && verify_checksum "$package_filename" "$checksum"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Reuse previously downloaded file in cache location
|
||||
[ -n "$PYTHON_BUILD_CACHE_PATH" ] || return 1
|
||||
local cached_package_filename="${PYTHON_BUILD_CACHE_PATH}/$package_filename"
|
||||
|
||||
[ -e "$cached_package_filename" ] || return 1
|
||||
verify_checksum "$cached_package_filename" "$checksum" >&4 2>&1 || return 1
|
||||
ln -s "$cached_package_filename" "$package_filename" >&4 2>&1 || return 1
|
||||
@@ -429,7 +435,7 @@ fetch_jar() {
|
||||
|
||||
local package_filename="${package_name}.jar"
|
||||
|
||||
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
|
||||
if ! reuse_existing_tarball "$package_filename" "$checksum"; then
|
||||
echo "Downloading ${package_filename}..." >&2
|
||||
http head "$mirror_url" &&
|
||||
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
|
||||
@@ -463,7 +469,7 @@ fetch_zip() {
|
||||
|
||||
local package_filename="${package_name}.zip"
|
||||
|
||||
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
|
||||
if ! reuse_existing_tarball "$package_filename" "$checksum"; then
|
||||
echo "Downloading ${package_filename}..." >&2
|
||||
http head "$mirror_url" &&
|
||||
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
|
||||
@@ -497,7 +503,7 @@ fetch_script() {
|
||||
|
||||
local package_filename="${package_name}.sh" # TODO: extract suffix from ${package_url}
|
||||
|
||||
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
|
||||
if ! reuse_existing_tarball "$package_filename" "$checksum"; then
|
||||
echo "Downloading ${package_filename}..." >&2
|
||||
http head "$mirror_url" &&
|
||||
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
|
||||
@@ -860,7 +866,9 @@ fix_rbx_gem_binstubs() {
|
||||
for file in "$gemdir"/*; do
|
||||
binstub="${bindir}/${file##*/}"
|
||||
rm -f "$binstub"
|
||||
sed -E "s:^#\!.+:#\!${bindir}/ruby:" < "$file" > "$binstub"
|
||||
{ echo "#!${bindir}/ruby"
|
||||
cat "$file"
|
||||
} > "$binstub"
|
||||
chmod +x "$binstub"
|
||||
done
|
||||
rm -rf "$gemdir"
|
||||
|
||||
Reference in New Issue
Block a user