1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-08 11:33:49 -05:00

Support linking to MacPorts ports installed from binary archives (#3272)

This commit is contained in:
Danny Kim
2025-06-14 02:38:35 -04:00
committed by GitHub
parent bf19366669
commit e13b5848be
2 changed files with 31 additions and 69 deletions

View File

@@ -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

View File

@@ -275,7 +275,7 @@ DEF
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include -I$PORT_PREFIX/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib -L$PORT_PREFIX/lib -Wl,-rpath,$PORT_PREFIX/lib" PKG_CONFIG_PATH=""
Python-3.6.2: CFLAGS="" CPPFLAGS="-I$PORT_PREFIX/include -I${TMP}/install/include" LDFLAGS="-L$PORT_PREFIX/lib -Wl,-rpath,$PORT_PREFIX/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH="${TMP}/lib/pkgconfig"
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
@@ -373,12 +373,9 @@ OUT
@test "yaml is linked from MacPorts" {
cached_tarball "Python-3.6.2"
yaml_libdir="$TMP/port-yaml"
mkdir -p "$yaml_libdir/opt/local"
stub uname '-s : echo Darwin'
stub sw_vers '-productVersion : echo 1010'
stub port "-q location libyaml : echo '$yaml_libdir'"
stub port "-q installed libyaml : echo ' libyaml @0.2.5_0 (active)'"
for i in {1..3}; do stub port false; done
stub_make_install
@@ -391,7 +388,7 @@ OUT
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I$yaml_libdir/opt/local/include -I${TMP}/install/include -I${TMP}/include" LDFLAGS="-L$yaml_libdir/opt/local/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib -L${TMP}/lib -Wl,-rpath,${TMP}/lib" PKG_CONFIG_PATH=""
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/include -I${TMP}/install/include" LDFLAGS="-L${TMP}/lib -Wl,-rpath,${TMP}/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH="${TMP}/lib/pkgconfig"
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
@@ -401,12 +398,9 @@ OUT
@test "readline is linked from MacPorts" {
cached_tarball "Python-3.6.2"
readline_libdir="$TMP/port-readline"
mkdir -p "$readline_libdir/opt/local"
stub uname '-s : echo Darwin'
stub sw_vers '-productVersion : echo 1010'
stub port "-q location readline : echo '$readline_libdir'"
stub port "-q installed readline : echo ' readline @8.2.013_0 (active)'"
for i in {1..2}; do stub port false; done
stub_make_install
@@ -421,7 +415,7 @@ DEF
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I$readline_libdir/opt/local/include -I${TMP}/install/include -I${TMP}/include" LDFLAGS="-L$readline_libdir/opt/local/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib -L${TMP}/lib -Wl,-rpath,${TMP}/lib" PKG_CONFIG_PATH=""
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/include -I${TMP}/install/include" LDFLAGS="-L${TMP}/lib -Wl,-rpath,${TMP}/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH="${TMP}/lib/pkgconfig"
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
@@ -431,13 +425,10 @@ OUT
@test "ncurses is linked from MacPorts" {
cached_tarball "Python-3.6.2"
ncurses_libdir="$TMP/port-ncurses"
mkdir -p "$ncurses_libdir/opt/local"
stub uname '-s : echo Darwin'
stub sw_vers '-productVersion : echo 1010'
stub port false
stub port "-q location ncurses : echo '$ncurses_libdir'"
stub port "-q installed ncurses : echo '$ncurses_libdir'"
stub port false
stub_make_install
@@ -452,7 +443,7 @@ DEF
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I$ncurses_libdir/opt/local/include -I${TMP}/install/include -I${TMP}/include" LDFLAGS="-L$ncurses_libdir/opt/local/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib -L${TMP}/lib -Wl,-rpath,${TMP}/lib" PKG_CONFIG_PATH=""
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/include -I${TMP}/install/include" LDFLAGS="-L${TMP}/lib -Wl,-rpath,${TMP}/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH="${TMP}/lib/pkgconfig"
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
@@ -626,7 +617,7 @@ DEF
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include -I$PORT_PREFIX/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib -L$PORT_PREFIX/lib -Wl,-rpath,$PORT_PREFIX/lib" PKG_CONFIG_PATH=""
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/include -I${TMP}/install/include" LDFLAGS="-L${TMP}/lib -Wl,-rpath,${TMP}/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH="${TMP}/lib/pkgconfig"
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install