diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index e76ac01c..3e0f5421 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1507,8 +1507,9 @@ use_macports() { local port_location="$(command -v port)" if [ -n "$port_location" ]; then local prefix="${port_location%/bin/port}" - export CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }-I${prefix}/include" - append_ldflags_libs "-L${prefix}/lib -Wl,-rpath,${prefix}/lib" + export CPPFLAGS="-I${prefix}/include${CPPFLAGS:+ $CPPFLAGS}" + prepend_ldflags_libs "-L${prefix}/lib -Wl,-rpath,${prefix}/lib" + export PKG_CONFIG_PATH="$prefix/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" lock_in macports fi } @@ -1538,15 +1539,9 @@ use_homebrew_yaml() { use_macports_yaml() { can_use_macports || return 1 - local prefix="$(port -q location libyaml 2>/dev/null || true)" - if [ -n "$prefix" ]; then - local libdir="$prefix/opt/local" - if [ -d "$libdir" ]; then - echo "python-build: use libyaml from MacPorts" - export CPPFLAGS="-I$libdir/include${CPPFLAGS:+ $CPPFLAGS}" - export LDFLAGS="-L$libdir/lib${LDFLAGS:+ ${LDFLAGS% }}" - lock_in macports - fi + if [[ $(port -q installed libyaml | awk '{print $3}') == "(active)" ]]; then + echo "python-build: use libyaml from MacPorts" + lock_in macports else return 1 fi @@ -1615,15 +1610,9 @@ use_homebrew_readline() { use_macports_readline() { can_use_macports || return 1 if ! configured_with_package_dir "python" "readline/rlconf.h"; then - local prefix="$(port -q location readline 2>/dev/null || true)" - if [ -n "$prefix" ]; then - local libdir="$prefix/opt/local" - if [ -d "$libdir" ]; then - echo "python-build: use readline from MacPorts" - export CPPFLAGS="-I$libdir/include${CPPFLAGS:+ $CPPFLAGS}" - export LDFLAGS="-L$libdir/lib${LDFLAGS:+ $LDFLAGS}" - lock_in macports - fi + if [[ $(port -q installed readline | awk '{print $3}') == "(active)" ]]; then + echo "python-build: use readline from MacPorts" + lock_in macports else return 1 fi @@ -1645,15 +1634,9 @@ use_homebrew_ncurses() { use_macports_ncurses() { can_use_macports || return 1 - local prefix="$(port -q location ncurses 2>/dev/null || true)" - if [[ -n "$prefix" ]]; then - local libdir="$prefix/opt/local" - if [ -d "$libdir" ]; then - echo "python-build: use ncurses from MacPorts" - export CPPFLAGS="-I$libdir/include${CPPFLAGS:+ $CPPFLAGS}" - export LDFLAGS="-L$libdir/lib${LDFLAGS:+ $LDFLAGS}" - lock_in macports - fi + if [[ $(port -q installed ncurses | awk '{print $3}') == "(active)" ]]; then + echo "python-build: use ncurses from MacPorts" + lock_in macports else return 1 fi @@ -1724,22 +1707,16 @@ use_homebrew_openssl() { use_macports_openssl() { can_use_macports || return 1 command -v port >/dev/null || return 1 + local port_location="$(command -v port)" + local prefix="${port_location%/bin/port}" for openssl in ${PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA:-openssl}; do - local ssldir="$(port -q location "${openssl}" 2>/dev/null || true)" - if [ -n "$ssldir" ]; then - ssldir="${ssldir}/opt/local" - if [ -d "$ssldir" ]; then - echo "python-build: use ${openssl} from MacPorts" - if [[ -n "${PYTHON_BUILD_CONFIGURE_WITH_OPENSSL:-}" ]]; then - # configure script of newer CPython versions support `--with-openssl` - # https://bugs.python.org/issue21541 - package_option python configure --with-openssl="${ssldir}" - else - export CPPFLAGS="-I$ssldir/include ${CPPFLAGS:+ $CPPFLAGS}" - export LDFLAGS="-L$ssldir/lib${LDFLAGS:+ $LDFLAGS}" - fi + if [[ $(port -q installed ${openssl} | awk '{print $3}') == "(active)" ]]; then + echo "python-build: use ${openssl} from MacPorts" + if [[ -n "${PYTHON_BUILD_CONFIGURE_WITH_OPENSSL:-}" ]]; then + # configure script of newer CPython versions support `--with-openssl` + # https://bugs.python.org/issue21541 + package_option python configure --with-openssl="${prefix}" fi - export PKG_CONFIG_PATH="$ssldir/lib/pkgconfig/:${PKG_CONFIG_PATH}" lock_in macports return 0 fi @@ -1863,15 +1840,9 @@ use_xcode_sdk_zlib() { use_macports_zlib() { can_use_macports || return 1 - local prefix="$(port -q location zlib 2>/dev/null || true)" - if [[ -n "$prefix" ]]; then - local libdir="$prefix/opt/local" - if [[ -d "$libdir" ]]; then - echo "python-build: use zlib from MacPorts" - export CPPFLAGS="-I$prefix/include ${CPPFLAGS}" - export LDFLAGS="-L$prefix/lib ${LDFLAGS}" - lock_in macports - fi + if [[ $(port -q installed zlib | awk '{print $3}') == "(active)" ]]; then + echo "python-build: use zlib from MacPorts" + lock_in macports else return 1 fi diff --git a/plugins/python-build/test/build.bats b/plugins/python-build/test/build.bats index 0f2aab0e..01e48630 100644 --- a/plugins/python-build/test/build.bats +++ b/plugins/python-build/test/build.bats @@ -275,7 +275,7 @@ DEF unstub make assert_build_log <