From d5fa1e225e1db461cdea53f0e9b6c691d215ea03 Mon Sep 17 00:00:00 2001 From: Tekin Tian Date: Sat, 7 Mar 2026 16:44:57 +0800 Subject: [PATCH] Fix MacPorts OpenSSL formula detection (#3417) Co-authored-by: Ivan Pozdeev --- plugins/python-build/README.md | 1 + plugins/python-build/bin/python-build | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/python-build/README.md b/plugins/python-build/README.md index 22dc2420..93e66120 100644 --- a/plugins/python-build/README.md +++ b/plugins/python-build/README.md @@ -175,6 +175,7 @@ You can set certain environment variables to control the build process. * `PYTHON_BUILD_SKIP_HOMEBREW`, if set, will not search for libraries installed by Homebrew when it would normally will. * `PYTHON_BUILD_USE_HOMEBREW`, if set, will search for libraries installed by Homebrew when it would normally not. * `PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA`, override the Homebrew OpenSSL formula to use. +* `PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA`, override the MacPorts OpenSSL formula to use. The default is `openssl3 openssl`. * `PYTHON_BUILD_TCLTK_FORMULA`, override the Homebrew Tcl/Tk formula to use. * `PYTHON_BUILD_SKIP_MACPORTS`, if set, will not search for libraries installed by MacPorts when it would normally will. * `PYTHON_BUILD_USE_MACPORTS`, if set, will search for libraries installed by MacPorts when it would normally not. diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 41edeefc..30a10b97 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1663,12 +1663,20 @@ prefer_openssl11() { # Allow overriding the preference of OpenSSL version per definition basis (#1302, #1325, #1326) PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA="${PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA:-openssl@1.1 openssl}" export PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA + + PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA="${PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA:-openssl11 openssl3 openssl}" + export PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA + } prefer_openssl3() { # Allow overriding the preference of OpenSSL version per definition basis (#1302, #1325, #1326) PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA="${PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA:-openssl@3 openssl@1.1 openssl}" export PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA + + # Set MacPorts OpenSSL formula names for MacPorts environment + PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA="${PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA:-openssl3 openssl openssl11}" + export PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA } build_package_mac_readline() { @@ -1727,7 +1735,8 @@ use_macports_openssl() { 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 + # MacPorts uses a different package naming convention and does not use the @ symbol. + for openssl in ${PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA:-openssl3 openssl}; do 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