python-build: honor explicitly configured OpenSSL on macOS - #3541
python-build: honor explicitly configured OpenSSL on macOS#3541aprylewu wants to merge 3 commits into
Conversation
Skip automatic OpenSSL selection when configure options supply --with-openssl, while keeping rpath-only options on the existing detection path. Assisted-by: OpenAI Codex Signed-off-by: Mingyang Wu <129849514+aprylewu@users.noreply.github.com>
native-api
left a comment
There was a problem hiding this comment.
Will this also prevent picking OpenSSL from Homebrew/MacPorts?
IIRC after has_broken_mac_openssl, OpenSSL search triggers again at some point.
FWIW, scripts aren't required to call has_broken_mac_openssl at all.
Share the explicit OpenSSL check between the broken-system predicate and both package-manager selectors. Return success without discovery when already configured so custom definitions cannot fall through to another OpenSSL installation. Signed-off-by: Mingyang Wu <129849514+aprylewu@users.noreply.github.com>
|
Good point: the original guard only covered Commit b567c52 factors out the option check and applies it to both Added four regressions for direct calls without the predicate and repeated calls after it, covering both package managers. All four fail on the previous head and pass now. All 10 OpenSSL cases and the full suite pass on Bash 3.2 (470 passed, 9 skipped); no CPython/OpenSSL compilation was needed. |
| } | ||
|
|
||
| use_homebrew_openssl() { | ||
| configured_with_openssl && return 0 |
There was a problem hiding this comment.
Yes, changed both to return 1 in f5c262e. has_broken_mac_openssl still has its own guard to skip the bundled build.
| local arg | ||
| for arg in ${CONFIGURE_OPTS} ${PYTHON_CONFIGURE_OPTS} "${PYTHON_CONFIGURE_OPTS_ARRAY[@]}"; do | ||
| [[ "$arg" = --with-openssl || "$arg" = --with-openssl=* ]] && return 1 | ||
| [[ "$arg" = --with-openssl || "$arg" = --with-openssl=* ]] && return 0 |
There was a problem hiding this comment.
Replace with =~ --with-openssl[ =] ?
There was a problem hiding this comment.
Switched to ^--with-openssl(=|$) per argument. That also handles --with-openssl /path, while keeping --with-openssl-rpath out.
Return nonzero when neither package-manager selector selects an OpenSSL installation. Keep the separate explicit-config guard in the bundled build predicate and use an anchored regex for each configure argument. Signed-off-by: Mingyang Wu <129849514+aprylewu@users.noreply.github.com>
native-api
left a comment
There was a problem hiding this comment.
Looking through the code, I confirmed that indeed, OpenSSL search is indeed currently only triggered from has_broken_mac_openssl.
We probably need to do that more like the Tcl-related code does.
Maybe even refactor all OpenSSL search logic into a subroutine like #3399 suggests.
|
Agreed. OpenSSL discovery being a side effect of I read through #3399. A shared selection routine needs to preserve the version constraints, source-build fallback and custom definitions. I'd suggest keeping that refactor separate and this PR focused on honoring explicit |
|
Here's the design I had in mind: add probing of OpenSSL within plugins/python-build/bin/python-build | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build
index 6a651ed0..0a802722 100755
--- a/plugins/python-build/bin/python-build
+++ b/plugins/python-build/bin/python-build
@@ -873,6 +873,7 @@ build_package_standard_build() {
if [ "$package_var_name" = "PYTHON" ]; then
if can_use_homebrew; then
+ configured_with_openssl || use_homebrew_openssl || true
use_custom_tcltk || use_homebrew_tcltk || true
use_homebrew_readline || true
use_homebrew_ncurses || true
@@ -885,6 +886,7 @@ build_package_standard_build() {
fi
fi
if can_use_macports; then
+ configured_with_openssl || use_macports_openssl || true
use_custom_tcltk || true
use_macports_readline || true
use_macports_ncurses || true
@@ -1729,7 +1731,6 @@ has_broken_mac_openssl() {
}
use_homebrew_openssl() {
- configured_with_openssl && return 1
can_use_homebrew || return 1
command -v brew >/dev/null || return 1
for openssl in ${PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA:-openssl}; do
@@ -1768,7 +1769,6 @@ use_homebrew_openssl() {
}
use_macports_openssl() {
- configured_with_openssl && return 1
can_use_macports || return 1
command -v port >/dev/null || return 1
local port_location="$(command -v port)" |
When a macOS build supplies
--with-openssl, Python-Build still selects an OpenSSL installation from Homebrew and prepends its include, library, and runtime search paths. The explicit configure option survives, but the injected flags can refer to a different installation.Skip automatic OpenSSL selection when an explicit
--with-opensslargument is present. Recognize both argument forms inCONFIGURE_OPTS,PYTHON_CONFIGURE_OPTS, and definition-provided package options. The check also covers definitions that call the Homebrew/MacPorts OpenSSL selectors directly or repeatedly. A standalone--with-openssl-rpathstill allows automatic selection. General dependency-prefix flags are unchanged.Prerequisite
Tests
python-buildentry point using tiny local source fixtures and stubbed build commands, plus four direct/repeated-selector regressions requested during review. The original cases fail on the base revision; the four follow-up cases fail on the previous PR head. All pass with this change.--with-openssl-rpathalone and the bundled fallback when no OpenSSL location is configured or found.extglobenabled andgit diff --check.make teston macOS with Bash 3.2 and Bats 1.10.0: 470 passed, 9 skipped (fish/PowerShell are unavailable; the Linuxldconfig -pcase does not apply).The fixtures inspect configure arguments and compiler flags; no CPython or OpenSSL compilation is performed locally.
Implementation and regression tests were prepared with assistance from OpenAI Codex.
Summary by cubic
Honors an explicitly configured OpenSSL on macOS so automatic Homebrew or MacPorts selection no longer overrides it.
python-buildnow treats--with-openssland--with-openssl=...inCONFIGURE_OPTS,PYTHON_CONFIGURE_OPTS, and package options as an explicit choice. It skips Homebrew/MacPorts discovery, skips the bundled OpenSSL fallback, and still allows automatic selection when only--with-openssl-rpathis present. The guard also applies when definitions call the Homebrew or MacPorts selectors directly or repeatedly. Closespyenv/pyenvissue #2852.Tests
Written for commit f5c262e. Summary will update on new commits.