Skip to content

sys._base_executable in framework builds does not take into account ABI build flag #124861

Open
@ned-deily

Description

@ned-deily

For 3.13.0, we now provide separate Python.framework and PythonT.framework builds with the python.org macOS installer in an attempt to keep the two installed variants as independent as possible while the free-treading feature is classified as experimental. One goal of this is to ensure that there are no duplicate file names in the two framework bin directories, ending up with i.e. python3.13 in one and python3.13t in the other.

Unfortunately, it was discovered that removing python3.13 in the PythonT.framework bin directory breaks venv support. The root cause is the code that was added to Modules/getpath.py by #31958 which fixed another problem with framework venv support by setting sys._base_executable (which venv uses) to:

base_executable = f"{dirname(library)}/bin/python{VERSION_MAJOR}.{VERSION_MINOR}"

Note that this path does not take into account the ABI build tag, meaning that any framework builds using a configuration option that appends a non-blank ABI, like --disable-gil -> t or --with-pydebug -> d or both (td) needs to keep a non-suffixed python3.x in its framework bin directory for venv executions to work. And that can cause unnoticed ambiguities if users add both framework bin directories to a shell PATH which could be expected to be a common occurrence.

For 3.13.0, we handwave around the problem in the macOS installer by leaving an unsuffixed python3.13 in the PythonT.framework bin directory and by not supporting the free-threaded variant in the Update Shell Profile.command and installer post-installation script. But it should be fixed and, if possible, in a way that does not break existing virtual environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixesOS-mactopic-venvRelated to the venv module

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions