Skip to content

Fix MacPorts OpenSSL formula detection#3416

Closed
tekintian wants to merge 1 commit intopyenv:masterfrom
tekintian:master
Closed

Fix MacPorts OpenSSL formula detection#3416
tekintian wants to merge 1 commit intopyenv:masterfrom
tekintian:master

Conversation

@tekintian
Copy link
Copy Markdown
Contributor

@tekintian tekintian commented Mar 7, 2026

  • Modify prefer_openssl3 to detect MacPorts environment and use appropriate package names
  • Update use_macports_openssl to use PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA instead of PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA
  • Prevents 'Error: No available formula with the name [email protected]' when using MacPorts"

Make sure you have checked all steps below.

Prerequisite

  • Please consider implementing the feature as a hook script or plugin as a first step.
    • I considered implementing this as a plugin, but this issue affects core functionality and is better fixed in the core code.
  • Please consider contributing the patch upstream to https://github.com/rbenv/rbenv
    • I checked rbenv, and it doesn't have MacPorts-related code. This is a pyenv-specific issue.
  • My PR addresses the following pyenv issue (if any)

Description

  • Here are some details about my PR
    Fixed the issue where pyenv tries to find non-existent Homebrew package names (like [email protected]) in MacPorts environment, causing installation failures.

    1. Modified prefer_openssl3 to set both HOMEBREW and MACPORTS OpenSSL formula variables
    2. Let individual functions check for package manager presence rather than checking in prefer_openssl3
    3. Added documentation for new PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA environment variable in README

Tests

  • My PR adds the following unit tests (if any)
    Tested Python 3.11.15 installation in MacPorts environment, confirming that the "Error: No available formula" error no longer occurs.

    Test environment:

    • macOS with MacPorts installed
    • pyenv with python-build plugin
    • Multiple Python versions tested (3.9, 3.10, 3.11)

Additional Context

This issue affects users who use MacPorts instead of Homebrew as their package manager on macOS. The root cause is that MacPorts uses different package naming conventions (without the @ symbol) compared to Homebrew. When pyenv tries to find Homebrew-style package names in MacPorts, it fails with the error "Error: No available formula with the name '[email protected]'".

This fix makes pyenv more package manager-agnostic by detecting the environment and using appropriate package names.

- Modify prefer_openssl3 to detect MacPorts environment and use appropriate package names
- Update use_macports_openssl to use PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA instead of PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA
- Prevents 'Error: No available formula with the name [email protected]' when using MacPorts"
@tekintian tekintian requested review from a team as code owners March 7, 2026 04:39
# 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 [email protected] openssl}"
export PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA
if can_use_macports; then
Copy link
Copy Markdown
Member

@native-api native-api Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to check for MacPorts presence here. Just set both envvars. The functions that actually use them check for presence.

export PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA
if can_use_macports; then
# MacPorts uses a different package naming convention and does not use the @ symbol.
PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA="${PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA:-openssl3 openssl}"
Copy link
Copy Markdown
Member

@native-api native-api Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to document the new envvar in the README

@tekintian
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! I've updated the PR to:

  1. Simplify the prefer_openssl3 function to set both HOMEBREW and MACPORTS OpenSSL formula variables
  2. Let individual functions check for package manager presence
  3. Document the new PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA environment variable in the python-build README

The changes are now pushed to the same branch. Please let me know if any further adjustments are needed.

@native-api
Copy link
Copy Markdown
Member

The changes are now pushed to the same branch.

...or are they?.. I don't see any changes.

@tekintian
Copy link
Copy Markdown
Contributor Author

The changes are now pushed to the same branch.

...or are they?.. I don't see any changes.

here #3417

@tekintian tekintian closed this Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants