Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ned-deily opened this issue Oct 1, 2024 · 0 comments
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes OS-mac topic-venv Related to the venv module

Comments

@ned-deily
Copy link
Member

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.

@ned-deily ned-deily added OS-mac 3.13 bugs and security fixes topic-venv Related to the venv module 3.14 bugs and security fixes labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes OS-mac topic-venv Related to the venv module
Projects
None yet
Development

No branches or pull requests

1 participant