fix: fix venv paths redirected by Python from MS Store #5931
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.
Running Poetry with Python installed from the Microsoft Store have to tackle multiple issues.
The system's Python interpreter is located at something like
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0
. But the user is not allowed to run any executable from there. Instead one should use the binaries locates atC:\Users\username\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\
.Another problem us, that applications from the Microsoft Store are not allowed to write directly into
%LocalAppdata%
, instead any attempt to do this is redirected to a sandbox folder located atC:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0
.The first problem described above is an issue, when trying to find the interpreter, that should be used for creating a new venv. This can be solved by replacing the
%ProgramFiles%
part of the path by%LocalAppdata/Microsoft%
.The second problem described above is an issue, when a new venv should be created at the default location under
C:\Users\klare\AppData\Local\pypoetry\Cache\virtualenvs
. Fortunately when one try to access this place during runtime, thePath
object is a symlink that can be resolved and than be passed to the subprocess call that creates the venv.This
install-poetry.py
script is affected by the same problems. A possible fix is prepared at python-poetry/install.python-poetry.org#18Resolves: #5331