From 819e2b8f454d8cf0b27a212eb99d7032c1798b50 Mon Sep 17 00:00:00 2001 From: native-api Date: Thu, 19 Jan 2023 00:21:10 +0300 Subject: [PATCH] Fix wrong libpython being linked to in MacOS (#2596) Without rpath, python would link up to the system's libpython --- plugins/python-build/bin/python-build | 6 +- plugins/python-build/test/build.bats | 102 +++++++++++------------ plugins/python-build/test/compiler.bats | 45 +++++----- plugins/python-build/test/pyenv_ext.bats | 10 +-- 4 files changed, 84 insertions(+), 79 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 7a1feceb..f0e88234 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1199,7 +1199,7 @@ require_gcc() { export CC="$gcc" if is_mac -ge 1010; then - export MACOSX_DEPLOYMENT_TARGET=10.9 + export MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-10.9} fi } @@ -2208,8 +2208,8 @@ package_option python configure --libdir="${PREFIX_PATH}/lib" # python-build: Set `RPATH` if `--enable-shared` was given (#65, #66, #82) if [[ "$CONFIGURE_OPTS $PYTHON_CONFIGURE_OPTS ${PYTHON_CONFIGURE_OPTS_ARRAY[@]}" == *"--enable-shared"* ]]; then # The ld on Darwin embeds the full paths to each dylib by default - if [[ "$LDFLAGS" != *"-rpath="* ]] && ! is_mac; then - export LDFLAGS="-Wl,-rpath=${PREFIX_PATH}/lib${LDFLAGS:+ $LDFLAGS}" + if [[ "$LDFLAGS" != *"-rpath="* ]] ; then + export LDFLAGS="-Wl,-rpath,${PREFIX_PATH}/lib${LDFLAGS:+ $LDFLAGS}" fi fi diff --git a/plugins/python-build/test/build.bats b/plugins/python-build/test/build.bats index aec81843..76a6b6a5 100644 --- a/plugins/python-build/test/build.bats +++ b/plugins/python-build/test/build.bats @@ -62,7 +62,7 @@ assert_build_log() { cached_tarball "yaml-0.1.6" cached_tarball "Python-3.6.2" - for i in {1..10}; do stub uname '-s : echo Linux'; done + for i in {1..9}; do stub uname '-s : echo Linux'; done stub brew false stub_make_install stub_make_install @@ -74,11 +74,11 @@ assert_build_log() { unstub make assert_build_log <>"$tcl_tk_libdir/lib/tclConfig.sh" - for i in {1..10}; do stub uname '-s : echo Darwin'; done + for i in {1..9}; do stub uname '-s : echo Darwin'; done for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done stub brew false @@ -405,7 +405,7 @@ DEF unstub make assert_build_log <> build.log' stub_make_install @@ -770,7 +770,7 @@ DEF assert_build_log <&2; echo 4.2.1' '--version : echo warning >&2; echo 4.2.1' + stub gcc '--version : echo warning >&2; echo 4.2.1' run_inline_definition <> build.log" \ " : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'" @@ -324,7 +324,7 @@ EOS assert_success assert_build_log <