From 42bb40a5d837451e203c068dfa3d1c3596ac8ede Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sat, 11 Oct 2014 00:13:20 +0900 Subject: [PATCH 1/2] Try to set `rpath` for `--shared` build of PyPy (#244) --- plugins/python-build/bin/python-build | 28 ++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 4c2817f3..e388f4e2 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -804,8 +804,13 @@ pypy_architecture() { build_package_pypy() { build_package_copy - { if [ -x "${PREFIX_PATH}/bin/pypy" ] && [ ! -x "${PREFIX_PATH}/bin/python" ]; then - ( cd "${PREFIX_PATH}/bin" && ln -fs pypy python ) + { if [ ! -x "${PREFIX_PATH}/bin/python" ]; then + if [ -x "${PREFIX_PATH}/bin/pypy" ]; then + ( cd "${PREFIX_PATH}/bin" && ln -fs "pypy" "python" ) + else + echo "not a pypy binary distribution" 1>&3 + return 1 + fi fi } >&4 2>&1 } @@ -819,10 +824,14 @@ build_package_pypy_builder() { echo "not a pypy source tree" 1>&3 return 1 fi - if [ -x "pypy-c" ] && [ ! -x "bin/pypy" ]; then - mkdir -p "bin" - mv -f "pypy-c" "bin/pypy" - fi + { mkdir -p "bin" "lib" + if [ -x "pypy-c" ]; then + mv -f "pypy-c" "bin/pypy" + fi + for libpypy in "libpypy-c."*; do + mv -f "${libpypy}" "lib/" + done + } >&4 2>&1 build_package_pypy } @@ -1593,7 +1602,7 @@ if [ -n "$DEBUG" ]; then package_option python configure --with-pydebug fi -# python-build: Set `RPATH` if `--enable-shared` was given (#65, #66, 82) +# 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 @@ -1601,6 +1610,11 @@ if [[ "$CONFIGURE_OPTS" == *"--enable-shared"* ]] || [[ "$PYTHON_CONFIGURE_OPTS" fi fi +# python-build: Set `RPATH` if --shared` was given for PyPy (#244) +if [[ "$PYPY_OPTS" == *"--shared"* ]]; then + export LDFLAGS="-Wl,-rpath=${PREFIX_PATH}/lib ${LDFLAGS}" +fi + # Add support for framework installation (`--enable-framework`) of CPython (#55, #99) if [[ "$PYTHON_CONFIGURE_OPTS" == *"--enable-framework"* ]]; then if [[ "Darwin" != "$(uname -s)" ]]; then From 58e24a64a21ab93c126b57341b81cc5ff5b5dba4 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sat, 11 Oct 2014 01:40:17 +0900 Subject: [PATCH 2/2] Set PYENV_VERSION on building pypy from source --- plugins/python-build/bin/pyenv-install | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugins/python-build/bin/pyenv-install b/plugins/python-build/bin/pyenv-install index 677f5c8b..7d585aff 100755 --- a/plugins/python-build/bin/pyenv-install +++ b/plugins/python-build/bin/pyenv-install @@ -182,6 +182,26 @@ if [[ "${VERSION_NAME}" == [23]"."* ]]; then done fi +# PyPy requires existing Python 2.x to build +if [[ "${VERSION_NAME}" == "pypy-"*"-src" ]]; then + PYENV_VERSION="$(pyenv-whence "python2.7" 2>/dev/null | tail -n 1 || true)" + if [ -n "${PYENV_VERSION}" ]; then + export PYENV_VERSION + else + PYENV_VERSION="$(pyenv-whence "python2.6" 2>/dev/null | tail -n 1 || true)" + if [ -n "${PYENV_VERSION}" ]; then + export PYENV_VERSION + else + PYENV_VERSION="$(pyenv-whence "python2.5" 2>/dev/null | tail -n 1 || true)" + if [ -n "${PYENV_VERSION}" ]; then + export PYENV_VERSION + else + echo "pyenv-install: $VERSION_NAME requires CPython 2.[567] to build" >^2 + exit 1 + fi + fi + fi +fi # Execute `before_install` hooks. for hook in "${before_hooks[@]}"; do eval "$hook"; done