From bc13a87beebfafb0e1baa352c0ba396fae4754b0 Mon Sep 17 00:00:00 2001 From: native-api Date: Sun, 5 Jun 2022 22:35:56 +0300 Subject: [PATCH] Add flags for Homebrew into `python-config --ldflags` (#2384) --- plugins/python-build/bin/python-build | 7 +++++-- plugins/python-build/test/build.bats | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index a4a3af78..c93589ae 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1300,7 +1300,7 @@ require_osx_version() { configured_with_package_dir() { local package_var_name="$(capitalize "$1")" - shift 1 + shift 3 local PACKAGE_CONFIGURE_OPTS="${package_var_name}_CONFIGURE_OPTS" local PACKAGE_CONFIGURE_OPTS_ARRAY="${package_var_name}_MAKE_OPTS_ARRAY[@]" local arg flag @@ -1330,7 +1330,10 @@ use_homebrew() { # /usr/local/lib:/usr/lib is the default library search path if [[ -n $brew_prefix && $brew_prefix != "/usr" && $brew_prefix != "/usr/local" ]]; then export CPPFLAGS="${CPPFLAGS:+${CPPFLAGS% } }-I${brew_prefix}/include" - export LDFLAGS="${LDFLAGS:+${LDFLAGS% } }-L${brew_prefix}/lib" + export LDFLAGS="${LDFLAGS:+${LDFLAGS% } }-L${brew_prefix}/lib -Wl,-rpath,${brew_prefix}/lib" + # `python-config` ignores LDFLAGS envvar. Adding to LIBS is the only way to add extra stuff + # to `python-config --ldflags` output + export LIBS="${LIBS:+${LIBS% } }-L${brew_prefix}/lib -Wl,-rpath,${brew_prefix}/lib" fi fi } diff --git a/plugins/python-build/test/build.bats b/plugins/python-build/test/build.bats index e324c02d..1034f0ba 100644 --- a/plugins/python-build/test/build.bats +++ b/plugins/python-build/test/build.bats @@ -166,7 +166,7 @@ DEF unstub make assert_build_log <