Skip to content
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

fix: fix venv paths redirected by Python from MS Store #5931

Merged
merged 2 commits into from
Jul 15, 2022

Conversation

finswimmer
Copy link
Member

@finswimmer finswimmer commented Jun 29, 2022

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 at C:\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 at C:\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, the Path 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#18

Resolves: #5331

@finswimmer finswimmer force-pushed the python-ms-store branch 4 times, most recently from a37d7d1 to f881ed9 Compare June 30, 2022 09:30
@finswimmer finswimmer marked this pull request as ready for review June 30, 2022 09:55
@finswimmer finswimmer requested a review from a team June 30, 2022 09:55
@finswimmer finswimmer force-pushed the python-ms-store branch 3 times, most recently from 5ffda7d to 3766a98 Compare July 3, 2022 19:42
Copy link
Member

@neersighted neersighted left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the typing is a bit of a mess -- the get_real_windows_path function takes a Path but immediately coerces it back to a string. Why don't we make it accept a Union of str or Path since that is what goes on internally anyway?

@finswimmer
Copy link
Member Author

It looks like the typing is a bit of a mess -- the get_real_windows_path function takes a Path but immediately coerces it back to a string. Why don't we make it accept a Union of str or Path since that is what goes on internally anyway?

Good idea 👍

@finswimmer finswimmer requested a review from neersighted July 14, 2022 18:11
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to create Virtual Environment with MS Store Python
2 participants