python / python/cpython

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

Open
#124,861 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.13 3.14 OS-mac topic-venv
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read Modules/getpath.py and the framework path logic first; trace how sys._base_executable is consumed by venv. Compare normal and ABI-suffixed framework builds, then verify that existing virtual environments and the distinct Python.framework/PythonT.framework bin names remain usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.