Skip to content

Switch to sys.base_prefix for better Lib path detection - #160

Open
Linus-XZX wants to merge 1 commit into
ModOrganizer2:masterfrom
Linus-XZX:master
Open

Switch to sys.base_prefix for better Lib path detection#160
Linus-XZX wants to merge 1 commit into
ModOrganizer2:masterfrom
Linus-XZX:master

Conversation

@Linus-XZX

Copy link
Copy Markdown

This changes the approach to finding the Lib directory, from under parent dir of sys.executable to under sys.base_prefix.

The current approach fails when the Python interpreter invoked is from a virtual environment, since in that case the executable becomes \path\to\venv\Scripts\python.exe where the prefix Lib is \path\to\venv\Lib.

Changing src/proxy/build_pythoncore.py line 7 to use .parent.parent will make the assert go through, but then result in an empty pythoncore.zip, since the real libraries to include in the archive are under the base prefix rather than the venv's Lib.

This change should not hurt either if the interpreter is not in a venv, since in that case sys.base_prefix is just the same as the parent of sys.executable.

Tested with the base environment and venv, on both py managed and uv managed Python installations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant