mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-22 16:33:34 +00:00
Merge branch 'ruby-build-v20131030'
This commit is contained in:
commit
f7193b09fd
2 changed files with 81 additions and 67 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
PYTHON_BUILD_VERSION="20130628"
|
PYTHON_BUILD_VERSION="20131030"
|
||||||
|
|
||||||
set -E
|
set -E
|
||||||
exec 3<&2 # preserve original stderr at fd 3
|
exec 3<&2 # preserve original stderr at fd 3
|
||||||
|
@ -96,6 +96,17 @@ file_is_not_empty() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
num_cpu_cores() {
|
||||||
|
local num=""
|
||||||
|
if [ "Darwin" = "$(uname -s)" ]; then
|
||||||
|
num="$(sysctl -n hw.ncpu 2>/dev/null || true)"
|
||||||
|
elif [ -r /proc/cpuinfo ]; then
|
||||||
|
num="$(grep -c ^processor /proc/cpuinfo)"
|
||||||
|
[ "$num" -gt 0 ] || num=""
|
||||||
|
fi
|
||||||
|
echo "${num:-2}"
|
||||||
|
}
|
||||||
|
|
||||||
install_package() {
|
install_package() {
|
||||||
install_package_using "tarball" 1 "$@"
|
install_package_using "tarball" 1 "$@"
|
||||||
}
|
}
|
||||||
|
@ -267,36 +278,28 @@ fetch_tarball() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local tar_args="xzvf"
|
||||||
|
local package_filename="${package_name}.tar.gz"
|
||||||
|
|
||||||
local package_suffix extract_option
|
local package_suffix extract_option
|
||||||
case "${package_url}" in
|
case "${package_url}" in
|
||||||
*".tar.gz" )
|
|
||||||
package_suffix=".tar.gz"
|
|
||||||
extract_option="zxvf"
|
|
||||||
;;
|
|
||||||
*".tgz" )
|
*".tgz" )
|
||||||
package_suffix=".tgz"
|
package_filename="${package_name}.tgz"
|
||||||
extract_option="zxvf"
|
|
||||||
;;
|
;;
|
||||||
*".tar.bz2" )
|
*".tar.bz2" )
|
||||||
package_suffix=".tar.bz2"
|
package_filename="${package_name}.tar.bz2"
|
||||||
extract_option="jxvf"
|
tar_args="${tar_args/z/j}"
|
||||||
;;
|
|
||||||
* )
|
|
||||||
package_suffix=".${package_url##*.}"
|
|
||||||
extract_option="xvf"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
local package_filename="${package_name}${package_suffix:-.tar.gz}"
|
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
|
||||||
symlink_tarball_from_cache "$package_filename" "$checksum" || {
|
|
||||||
echo "Downloading ${package_filename}..." >&2
|
echo "Downloading ${package_filename}..." >&2
|
||||||
{ http head "$mirror_url" &&
|
http head "$mirror_url" &&
|
||||||
download_tarball "$mirror_url" "$package_filename" "$checksum"
|
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
|
||||||
} ||
|
|
||||||
download_tarball "$package_url" "$package_filename" "$checksum"
|
download_tarball "$package_url" "$package_filename" "$checksum"
|
||||||
}
|
fi
|
||||||
|
|
||||||
{ if tar "${extract_options:-xvf}" "$package_filename"; then
|
{ if tar $tar_args "$package_filename"; then
|
||||||
if [ -z "$KEEP_BUILD_PATH" ]; then
|
if [ -z "$KEEP_BUILD_PATH" ]; then
|
||||||
rm -f "$package_filename"
|
rm -f "$package_filename"
|
||||||
else
|
else
|
||||||
|
@ -327,9 +330,12 @@ download_tarball() {
|
||||||
|
|
||||||
echo "-> $package_url" >&2
|
echo "-> $package_url" >&2
|
||||||
|
|
||||||
{ http get "$package_url" "$package_filename"
|
if http get "$package_url" "$package_filename" >&4 2>&1; then
|
||||||
verify_checksum "$package_filename" "$checksum"
|
verify_checksum "$package_filename" "$checksum" >&4 2>&1 || return 1
|
||||||
} >&4 2>&1 || return 1
|
else
|
||||||
|
echo "error: failed to download $package_filename" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$PYTHON_BUILD_CACHE_PATH" ]; then
|
if [ -n "$PYTHON_BUILD_CACHE_PATH" ]; then
|
||||||
local cached_package_filename="${PYTHON_BUILD_CACHE_PATH}/$package_filename"
|
local cached_package_filename="${PYTHON_BUILD_CACHE_PATH}/$package_filename"
|
||||||
|
@ -431,26 +437,24 @@ fetch_jar() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local package_filename="${package_name}.jar"
|
local package_filename="${package_name}.jar"
|
||||||
symlink_jar_from_cache "$package_filename" "$checksum" || {
|
|
||||||
|
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
|
||||||
echo "Downloading ${package_filename}..." >&2
|
echo "Downloading ${package_filename}..." >&2
|
||||||
{ http head "$mirror_url" &&
|
http head "$mirror_url" &&
|
||||||
download_jar "$mirror_url" "$package_filename" "$checksum"
|
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
|
||||||
} ||
|
download_tarball "$package_url" "$package_filename" "$checksum"
|
||||||
download_jar "$package_url" "$package_filename" "$checksum"
|
fi
|
||||||
}
|
|
||||||
{ $JAVA -jar ${package_name}.jar -s -d ${package_name}
|
{ if $JAVA -jar ${package_name}.jar -s -d ${package_name}; then
|
||||||
rm -f "$package_filename"
|
if [ -z "$KEEP_BUILD_PATH" ]; then
|
||||||
|
rm -f "$package_filename"
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
} >&4 2>&1
|
} >&4 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
symlink_jar_from_cache() {
|
|
||||||
symlink_tarball_from_cache "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
download_jar() {
|
|
||||||
download_tarball "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch_zip() {
|
fetch_zip() {
|
||||||
local package_name="$1"
|
local package_name="$1"
|
||||||
local package_url="$2"
|
local package_url="$2"
|
||||||
|
@ -467,13 +471,13 @@ fetch_zip() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local package_filename="${package_name}.zip"
|
local package_filename="${package_name}.zip"
|
||||||
symlink_zip_from_cache "$package_filename" "$checksum" || {
|
|
||||||
|
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
|
||||||
echo "Downloading ${package_filename}..." >&2
|
echo "Downloading ${package_filename}..." >&2
|
||||||
{ http head "$mirror_url" &&
|
http head "$mirror_url" &&
|
||||||
download_zip "$mirror_url" "$package_filename" "$checksum"
|
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
|
||||||
} ||
|
download_tarball "$package_url" "$package_filename" "$checksum"
|
||||||
download_zip "$package_url" "$package_filename" "$checksum"
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
{ if unzip "$package_filename"; then
|
{ if unzip "$package_filename"; then
|
||||||
if [ -z "$KEEP_BUILD_PATH" ]; then
|
if [ -z "$KEEP_BUILD_PATH" ]; then
|
||||||
|
@ -485,14 +489,6 @@ fetch_zip() {
|
||||||
} >&4 2>&1
|
} >&4 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
symlink_zip_from_cache() {
|
|
||||||
symlink_tarball_from_cache "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
download_zip() {
|
|
||||||
download_tarball "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
build_package() {
|
build_package() {
|
||||||
local package_name="$1"
|
local package_name="$1"
|
||||||
shift
|
shift
|
||||||
|
@ -526,7 +522,7 @@ build_package_standard() {
|
||||||
if [ "${MAKEOPTS+defined}" ]; then
|
if [ "${MAKEOPTS+defined}" ]; then
|
||||||
MAKE_OPTS="$MAKEOPTS"
|
MAKE_OPTS="$MAKEOPTS"
|
||||||
elif [ -z "${MAKE_OPTS+defined}" ]; then
|
elif [ -z "${MAKE_OPTS+defined}" ]; then
|
||||||
MAKE_OPTS="-j 2"
|
MAKE_OPTS="-j $(num_cpu_cores)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Support YAML_CONFIGURE_OPTS, PYTHON_CONFIGURE_OPTS, etc.
|
# Support YAML_CONFIGURE_OPTS, PYTHON_CONFIGURE_OPTS, etc.
|
||||||
|
@ -603,7 +599,7 @@ build_package_pypy_builder() {
|
||||||
|
|
||||||
build_package_copy() {
|
build_package_copy() {
|
||||||
mkdir -p "$PREFIX_PATH"
|
mkdir -p "$PREFIX_PATH"
|
||||||
cp -R . "$PREFIX_PATH"
|
cp -fR . "$PREFIX_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
before_install_package() {
|
before_install_package() {
|
||||||
|
@ -825,6 +821,16 @@ build_package_mac_openssl() {
|
||||||
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> "$pem_file"
|
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> "$pem_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Ensure that directories listed in LDFLAGS exist
|
||||||
|
build_package_ldflags_dirs() {
|
||||||
|
local arg
|
||||||
|
for arg in $LDFLAGS; do
|
||||||
|
case "$arg" in
|
||||||
|
-L* ) mkdir -p "${arg#-L}" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
has_broken_mac_readline() {
|
has_broken_mac_readline() {
|
||||||
[ "$(uname -s)" = "Darwin" ] &&
|
[ "$(uname -s)" = "Darwin" ] &&
|
||||||
_has_broken_mac_readline &&
|
_has_broken_mac_readline &&
|
||||||
|
@ -1058,6 +1064,8 @@ fi
|
||||||
PREFIX_PATH="${ARGUMENTS[1]}"
|
PREFIX_PATH="${ARGUMENTS[1]}"
|
||||||
if [ -z "$PREFIX_PATH" ]; then
|
if [ -z "$PREFIX_PATH" ]; then
|
||||||
usage
|
usage
|
||||||
|
elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then
|
||||||
|
PREFIX_PATH="${PWD}/${PREFIX_PATH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$TMPDIR" ]; then
|
if [ -z "$TMPDIR" ]; then
|
||||||
|
@ -1066,6 +1074,11 @@ else
|
||||||
TMP="${TMPDIR%/}"
|
TMP="${TMPDIR%/}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -w "$TMP" ] || [ ! -x "$TMP" ]; then
|
||||||
|
echo "python-build: TMPDIR=$TMP is set to a non-accessible location" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Work around warnings building Ruby 2.0 on Clang 2.x:
|
# Work around warnings building Ruby 2.0 on Clang 2.x:
|
||||||
# pass -Wno-error=shorten-64-to-32 if the compiler accepts it.
|
# pass -Wno-error=shorten-64-to-32 if the compiler accepts it.
|
||||||
#
|
#
|
||||||
|
@ -1077,7 +1090,11 @@ fi
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
if [ -z "$MAKE" ]; then
|
if [ -z "$MAKE" ]; then
|
||||||
export MAKE="make"
|
if [[ "FreeBSD" = "$(uname -s)" ]]; then
|
||||||
|
export MAKE="gmake"
|
||||||
|
else
|
||||||
|
export MAKE="make"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$PYTHON_BUILD_CACHE_PATH" ] && [ -d "$PYTHON_BUILD_CACHE_PATH" ]; then
|
if [ -n "$PYTHON_BUILD_CACHE_PATH" ] && [ -d "$PYTHON_BUILD_CACHE_PATH" ]; then
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# Usage: PREFIX=/usr/local ./install.sh
|
||||||
|
#
|
||||||
|
# Installs python-build under $PREFIX.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
if [ -z "${PREFIX}" ]; then
|
if [ -z "${PREFIX}" ]; then
|
||||||
PREFIX="/usr/local"
|
PREFIX="/usr/local"
|
||||||
fi
|
fi
|
||||||
|
@ -9,15 +14,7 @@ fi
|
||||||
BIN_PATH="${PREFIX}/bin"
|
BIN_PATH="${PREFIX}/bin"
|
||||||
SHARE_PATH="${PREFIX}/share/python-build"
|
SHARE_PATH="${PREFIX}/share/python-build"
|
||||||
|
|
||||||
mkdir -p "${BIN_PATH}"
|
mkdir -p "$BIN_PATH" "$SHARE_PATH"
|
||||||
mkdir -p "${SHARE_PATH}"
|
|
||||||
|
|
||||||
for file in bin/*; do
|
install -p bin/* "$BIN_PATH"
|
||||||
cp "${file}" "${BIN_PATH}"
|
install -p share/python-build/* "$SHARE_PATH"
|
||||||
done
|
|
||||||
|
|
||||||
for file in share/python-build/*; do
|
|
||||||
cp -Rp "${file}" "${SHARE_PATH}"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Installed python-build at ${PREFIX}"
|
|
||||||
|
|
Loading…
Reference in a new issue