Merge pull request #1327 from pyenv/yy-import-ruby-build-20190401
Import ruby-build 20190401
This commit is contained in:
commit
3895488c53
@ -36,9 +36,6 @@ install: git clone --depth 1 https://github.com/bats-core/bats-core.git bats
|
|||||||
# Default for auto-generated jobs.
|
# Default for auto-generated jobs.
|
||||||
script: make test-build
|
script: make test-build
|
||||||
|
|
||||||
after_script: |
|
|
||||||
cat "$(ls -tr ${TMPDIR:-/tmp}/python-build.*.log | tail -1)"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
# Shell-based tests should execute every time.
|
# Shell-based tests should execute every time.
|
||||||
|
14
Makefile
14
Makefile
@ -8,8 +8,18 @@ test: bats
|
|||||||
PATH="./bats/bin:$$PATH" test/run
|
PATH="./bats/bin:$$PATH" test/run
|
||||||
cd plugins/python-build && $(PWD)/bats/bin/bats $${CI:+--tap} test
|
cd plugins/python-build && $(PWD)/bats/bin/bats $${CI:+--tap} test
|
||||||
|
|
||||||
test-build: bats
|
PYTHON_BUILD_ROOT := $(CURDIR)/plugins/python-build
|
||||||
cd plugins/python-build && $(PWD)/bats/bin/bats $${CI:+--tap} test/build
|
PYTHON_BUILD_OPTS ?= --verbose
|
||||||
|
PYTHON_BUILD_VERSION ?= 3.8-dev
|
||||||
|
PYTHON_BUILD_TEST_PREFIX ?= $(PYTHON_BUILD_ROOT)/test/build/tmp/dist
|
||||||
|
|
||||||
|
test-build:
|
||||||
|
$(RM) -r $(PYTHON_BUILD_TEST_PREFIX)
|
||||||
|
$(PYTHON_BUILD_ROOT)/bin/python-build $(PYTHON_BUILD_OPTS) $(PYTHON_BUILD_VERSION) $(PYTHON_BUILD_TEST_PREFIX)
|
||||||
|
[ -e $(PYTHON_BUILD_TEST_PREFIX)/bin/python ]
|
||||||
|
$(PYTHON_BUILD_TEST_PREFIX)/bin/python -V
|
||||||
|
[ -e $(PYTHON_BUILD_TEST_PREFIX)/bin/pip ]
|
||||||
|
$(PYTHON_BUILD_TEST_PREFIX)/bin/pip -V
|
||||||
|
|
||||||
bats:
|
bats:
|
||||||
git clone --depth 1 https://github.com/bats-core/bats-core.git bats
|
git clone --depth 1 https://github.com/bats-core/bats-core.git bats
|
||||||
|
@ -326,31 +326,25 @@ verify_checksum() {
|
|||||||
|
|
||||||
http() {
|
http() {
|
||||||
local method="$1"
|
local method="$1"
|
||||||
local url="$2"
|
[ -n "$2" ] || return 1
|
||||||
local file="$3"
|
shift 1
|
||||||
[ -n "$url" ] || return 1
|
|
||||||
|
|
||||||
local http_client
|
PYTHON_BUILD_HTTP_CLIENT="${PYTHON_BUILD_HTTP_CLIENT:-$(detect_http_client)}"
|
||||||
if [ -n "${PYTHON_BUILD_HTTP_CLIENT}" ]; then
|
[ -n "$PYTHON_BUILD_HTTP_CLIENT" ] || return 1
|
||||||
http_client="http_${method}_${PYTHON_BUILD_HTTP_CLIENT}"
|
|
||||||
else
|
"http_${method}_${PYTHON_BUILD_HTTP_CLIENT}" "$@"
|
||||||
if type aria2c &>/dev/null; then
|
}
|
||||||
http_client="http_${method}_aria2c"
|
|
||||||
elif type curl &>/dev/null; then
|
detect_http_client() {
|
||||||
http_client="http_${method}_curl"
|
local client
|
||||||
elif type wget &>/dev/null; then
|
for client in aria2c curl wget; do
|
||||||
# SSL Certificate error with older wget that does not support Server Name Indication (#60)
|
if type "$client" &>/dev/null; then
|
||||||
if [[ "$(wget --version 2>/dev/null || true)" = "GNU Wget 1.1"[0-3]* ]]; then
|
echo "$client"
|
||||||
echo "python-build: wget (< 1.14) doesn't support Server Name Indication. Please install curl (>= 7.18.1) and try again" >&2
|
return
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
http_client="http_${method}_wget"
|
|
||||||
else
|
|
||||||
echo "error: please install \`aria2c\`, \`curl\` or \`wget\` and try again" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
"${http_client}" "$url" "$file"
|
echo "error: please install \`aria2c\`, \`curl\`, or \`wget\` and try again" >&2
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
http_head_aria2c() {
|
http_head_aria2c() {
|
||||||
@ -387,6 +381,7 @@ fetch_tarball() {
|
|||||||
local package_url="$2"
|
local package_url="$2"
|
||||||
local mirror_url
|
local mirror_url
|
||||||
local checksum
|
local checksum
|
||||||
|
local extracted_dir
|
||||||
|
|
||||||
if [ "$package_url" != "${package_url/\#}" ]; then
|
if [ "$package_url" != "${package_url/\#}" ]; then
|
||||||
checksum="${package_url#*#}"
|
checksum="${package_url#*#}"
|
||||||
@ -419,7 +414,7 @@ fetch_tarball() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if ! reuse_existing_tarball "$package_filename" "$checksum"; then
|
if ! reuse_existing_tarball "$package_filename" "$checksum"; then
|
||||||
local tarball_filename=$(basename $package_url)
|
local tarball_filename="$(basename "$package_url")"
|
||||||
echo "Downloading ${tarball_filename}..." >&2
|
echo "Downloading ${tarball_filename}..." >&2
|
||||||
http head "$mirror_url" &&
|
http head "$mirror_url" &&
|
||||||
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
|
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
|
||||||
@ -427,6 +422,11 @@ fetch_tarball() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
{ if tar $tar_args "$package_filename"; then
|
{ if tar $tar_args "$package_filename"; then
|
||||||
|
if [ ! -d "$package_name" ]; then
|
||||||
|
extracted_dir="$(find_extracted_directory)"
|
||||||
|
mv "$extracted_dir" "$package_name"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$KEEP_BUILD_PATH" ]; then
|
if [ -z "$KEEP_BUILD_PATH" ]; then
|
||||||
rm -f "$package_filename"
|
rm -f "$package_filename"
|
||||||
else
|
else
|
||||||
@ -436,6 +436,17 @@ fetch_tarball() {
|
|||||||
} >&4 2>&1
|
} >&4 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
find_extracted_directory() {
|
||||||
|
for f in *; do
|
||||||
|
if [ -d "$f" ]; then
|
||||||
|
echo "$f"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "Extracted directory not found" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
fetch_nightly_tarball() {
|
fetch_nightly_tarball() {
|
||||||
local package_name="$1"
|
local package_name="$1"
|
||||||
local package_url="$2"
|
local package_url="$2"
|
||||||
@ -925,6 +936,13 @@ fix_jruby_shebangs() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
build_package_truffleruby() {
|
||||||
|
build_package_copy
|
||||||
|
|
||||||
|
cd "${PREFIX_PATH}"
|
||||||
|
./lib/truffle/post_install_hook.sh
|
||||||
|
}
|
||||||
|
|
||||||
remove_windows_files() {
|
remove_windows_files() {
|
||||||
cd "$PREFIX_PATH"
|
cd "$PREFIX_PATH"
|
||||||
rm -f bin/*.exe bin/*.dll bin/*.bat bin/jruby.sh
|
rm -f bin/*.exe bin/*.dll bin/*.bat bin/jruby.sh
|
||||||
@ -1223,9 +1241,9 @@ require_gcc() {
|
|||||||
|
|
||||||
colorize 1 "TO FIX THE PROBLEM"
|
colorize 1 "TO FIX THE PROBLEM"
|
||||||
if type brew &>/dev/null; then
|
if type brew &>/dev/null; then
|
||||||
echo ": Install Homebrew's apple-gcc42 package with this"
|
echo ": Install Homebrew's GCC package with this"
|
||||||
echo -n "command: "
|
echo -n "command: "
|
||||||
colorize 4 "brew tap homebrew/dupes ; brew install apple-gcc42"
|
colorize 4 "brew install gcc@4.9"
|
||||||
else
|
else
|
||||||
echo ": Install the official GCC compiler using these"
|
echo ": Install the official GCC compiler using these"
|
||||||
echo -n "packages: "
|
echo -n "packages: "
|
||||||
@ -1544,8 +1562,8 @@ build_package_mac_openssl() {
|
|||||||
local nokerberos
|
local nokerberos
|
||||||
[[ "$1" != openssl-1.0.* ]] || nokerberos=1
|
[[ "$1" != openssl-1.0.* ]] || nokerberos=1
|
||||||
|
|
||||||
# Compile a shared lib with zlib dynamically linked, no kerberos.
|
# Compile a shared lib with zlib dynamically linked.
|
||||||
package_option openssl configure --openssldir="$OPENSSLDIR" zlib-dynamic no-ssl2 no-ssl3 no-krb5 shared
|
package_option openssl configure --openssldir="$OPENSSLDIR" zlib-dynamic no-ssl3 shared ${nokerberos:+no-ssl2 no-krb5}
|
||||||
|
|
||||||
# Default MAKE_OPTS are -j 2 which can confuse the build. Thankfully, make
|
# Default MAKE_OPTS are -j 2 which can confuse the build. Thankfully, make
|
||||||
# gives precedence to the last -j option, so we can override that.
|
# gives precedence to the last -j option, so we can override that.
|
||||||
@ -1561,15 +1579,38 @@ build_package_mac_openssl() {
|
|||||||
|
|
||||||
# Post-install check that the openssl extension was built.
|
# Post-install check that the openssl extension was built.
|
||||||
build_package_verify_openssl() {
|
build_package_verify_openssl() {
|
||||||
"$RUBY_BIN" -e 'begin
|
"$RUBY_BIN" -e '
|
||||||
require "openssl"
|
manager = ARGV[0]
|
||||||
rescue LoadError
|
packages = {
|
||||||
$stderr.puts "The Ruby openssl extension was not compiled. Missing the OpenSSL lib?"
|
"apt-get" => Hash.new {|h,k| "lib#{k}-dev" }.update(
|
||||||
$stderr.puts "Configure options used:"
|
"openssl" => "libssl-dev",
|
||||||
require "rbconfig"; require "shellwords"
|
"zlib" => "zlib1g-dev"
|
||||||
RbConfig::CONFIG.fetch("configure_args").shellsplit.each { |arg| $stderr.puts " #{arg}" }
|
),
|
||||||
exit 1
|
"yum" => Hash.new {|h,k| "#{k}-devel" }.update(
|
||||||
end' >&4 2>&1
|
"yaml" => "libyaml-devel"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
failed = %w[openssl readline zlib yaml].reject do |lib|
|
||||||
|
begin
|
||||||
|
require lib
|
||||||
|
rescue LoadError
|
||||||
|
$stderr.puts "The Ruby #{lib} extension was not compiled."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if failed.size > 0
|
||||||
|
$stderr.puts "ERROR: Ruby install aborted due to missing extensions"
|
||||||
|
$stderr.print "Try running `%s install -y %s` to fetch missing dependencies.\n\n" % [
|
||||||
|
manager,
|
||||||
|
failed.map { |lib| packages.fetch(manager)[lib] }.join(" ")
|
||||||
|
] unless manager.empty?
|
||||||
|
$stderr.puts "Configure options used:"
|
||||||
|
require "rbconfig"; require "shellwords"
|
||||||
|
RbConfig::CONFIG.fetch("configure_args").shellsplit.each { |arg| $stderr.puts " #{arg}" }
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
' "$(basename "$(type -p yum apt-get | head -1)")" >&4 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ensure that directories listed in LDFLAGS exist
|
# Ensure that directories listed in LDFLAGS exist
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/env bats
|
|
||||||
|
|
||||||
load ../test_helper
|
|
||||||
export PATH="$BATS_TEST_DIRNAME/../../bin:$PATH"
|
|
||||||
|
|
||||||
export PYTHON_BUILD_VERSION="${PYTHON_BUILD_VERSION:-3.8-dev}"
|
|
||||||
|
|
||||||
@test "Python build works" {
|
|
||||||
run python-build "$PYTHON_BUILD_VERSION" "$BATS_TMPDIR/dist"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
[ -e "$BATS_TMPDIR/dist/bin/python" ]
|
|
||||||
run "$BATS_TMPDIR/dist/bin/python" -V
|
|
||||||
assert_success
|
|
||||||
"$BATS_TMPDIR/dist/bin/python" -V >&3 2>&3
|
|
||||||
|
|
||||||
[ -e "$BATS_TMPDIR/dist/bin/pip" ]
|
|
||||||
run "$BATS_TMPDIR/dist/bin/pip" -V
|
|
||||||
assert_success
|
|
||||||
"$BATS_TMPDIR/dist/bin/pip" -V >&3 2>&3
|
|
||||||
}
|
|
@ -103,7 +103,6 @@ export PYTHON_BUILD_CACHE_PATH=
|
|||||||
@test "existing tarball in build location is reused" {
|
@test "existing tarball in build location is reused" {
|
||||||
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||||
stub curl false
|
stub curl false
|
||||||
stub curl false
|
|
||||||
stub wget false
|
stub wget false
|
||||||
|
|
||||||
export -n PYTHON_BUILD_CACHE_PATH
|
export -n PYTHON_BUILD_CACHE_PATH
|
||||||
|
@ -20,7 +20,7 @@ setup() {
|
|||||||
|
|
||||||
@test "using aria2c if available" {
|
@test "using aria2c if available" {
|
||||||
export PYTHON_BUILD_ARIA2_OPTS=
|
export PYTHON_BUILD_ARIA2_OPTS=
|
||||||
export PYTHON_BUILD_HTTP_CLIENT="aria2c"
|
export -n PYTHON_BUILD_HTTP_CLIENT
|
||||||
stub aria2c "--allow-overwrite=true --no-conf=true -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
|
stub aria2c "--allow-overwrite=true --no-conf=true -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
|
||||||
|
|
||||||
install_fixture definitions/without-checksum
|
install_fixture definitions/without-checksum
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
export TMP="$BATS_TEST_DIRNAME/tmp"
|
export TMP="$BATS_TEST_DIRNAME/tmp"
|
||||||
export RUBY_BUILD_CURL_OPTS=
|
export PYTHON_BUILD_CURL_OPTS=
|
||||||
export RUBY_BUILD_HTTP_CLIENT="curl"
|
export PYTHON_BUILD_HTTP_CLIENT="curl"
|
||||||
|
|
||||||
if [ "$FIXTURE_ROOT" != "$BATS_TEST_DIRNAME/fixtures" ]; then
|
if [ "$FIXTURE_ROOT" != "$BATS_TEST_DIRNAME/fixtures" ]; then
|
||||||
export FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
|
export FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
|
||||||
export INSTALL_ROOT="$TMP/install"
|
export INSTALL_ROOT="$TMP/install"
|
||||||
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
|
||||||
|
if [ "FreeBSD" = "$(uname -s)" ]; then
|
||||||
|
PATH="/usr/local/bin:$PATH"
|
||||||
|
fi
|
||||||
PATH="$BATS_TEST_DIRNAME/../bin:$PATH"
|
PATH="$BATS_TEST_DIRNAME/../bin:$PATH"
|
||||||
PATH="$TMP/bin:$PATH"
|
PATH="$TMP/bin:$PATH"
|
||||||
export PATH
|
export PATH
|
||||||
|
Loading…
x
Reference in New Issue
Block a user