-
Notifications
You must be signed in to change notification settings - Fork 790
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
Adjust base Python lookup logic for Windows #2121
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
charliermarsh
commented
Mar 1, 2024
charliermarsh
force-pushed
the
charlie/home
branch
from
March 1, 2024 21:19
7856ed2
to
3dff50a
Compare
Moving to draft to (1) add tests and (2) change Windows logic a bit. |
charliermarsh
force-pushed
the
charlie/home
branch
2 times, most recently
from
March 2, 2024 21:59
85e176c
to
e57b4ce
Compare
charliermarsh
changed the title
Always use interpreter parent for home
Adjust base Python lookup logic for Windows
Mar 2, 2024
charliermarsh
force-pushed
the
charlie/home
branch
2 times, most recently
from
March 2, 2024 22:04
8272a19
to
6b1305c
Compare
konstin
approved these changes
Mar 3, 2024
charliermarsh
force-pushed
the
charlie/home
branch
from
March 3, 2024 17:39
6b1305c
to
61b267c
Compare
Linking python/cpython#114476 for future reference |
charliermarsh
added a commit
that referenced
this pull request
Mar 3, 2024
## Summary After #2121, the only remaining issue is that calling `canonicalize` on these Pythons returns an error. Closes #2105. ## Test Plan Uninstalled all python.org Pythons on my Windows machine, then created a virtualenv. The resulting config file: ``` Using Python 3.11.8 interpreter at: C:\Users\crmar\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe Creating virtualenv at: .venv Activate with: .venv\Scripts\activate PS C:\Users\crmar\workspace\puffin> cat .\.venv\pyvenv.cfg home = C:\Users\crmar\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0 implementation = CPython version_info = 3.11.8 include-system-site-packages = false uv = 0.1.13 prompt = puffin ``` Prior to this PR, it would fail with a canonicalization error. Prior to #2121, it would leave a "bad" Python in the config file: ``` Using Python 3.11.8 interpreter at: C:\Users\crmar\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe Creating virtualenv at: .venv Activate with: .venv\Scripts\activate PS C:\Users\crmar\workspace\puffin> cat .\.venv\pyvenv.cfg home = C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2288.0_x64__qbz5n2kfra8p0 implementation = CPython version_info = 3.11.8 include-system-site-packages = false uv = 0.1.13 prompt = puffin ``` Which, once activated, would fail with: ``` (venv) PS C:\Users\crmar\workspace\puffin> python No Python at '"C:\Users\crmar\AppData\Local\Programs\Python\Python312\python.exe' ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
When I install via the Windows Store,
interpreter.base_prefix
contains a bunch of resolved information that leads to a broken environment.Instead, we now use
sys._base_executable
on Windows by default, falling back tosys.base_prefix
if it doesn't exist. (There are some issues withsys.base_executable
that lead to complexity invirtualenv
, but they only affect POSIX.) Admittedly, I don't know whensys._base_executable
wouldn't exist. It exists in all the environments I've tested.Additionally, we use the system interpreter directly if we're outside of a virtualenv.