Skip to content

Documentation of sys.base_prefix is unclear when a virtual environment is created from another virtual environment #95469

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
pfmoore opened this issue Jul 30, 2022 · 0 comments
Labels
docs Documentation in the Doc dir

Comments

@pfmoore
Copy link
Member

pfmoore commented Jul 30, 2022

Documentation of the sys module

The documentation of sys.base_prefix states that "base_prefix and base_exec_prefix will remain pointing to the base Python installation (the one which the virtual environment was created from)"

In the case of creating one virtual environment from another:

python -m venv foo --without pip
foo/Scripts/python.exe -m venv bar --without-pip

sys.base_prefix in bar points to the system Python installation, not to foo. (Tested on Windows). I believe this behaviour is better, and I'm suspect that existing tools rely on it, but regardless of what is correct behaviour, the documentation should be more explicit about what the expected value of sys.base_prefix is in a virtual environment created from another virtual environment.

Also, given that the behaviour is documented as being (at least in part) implemented in site.py, the behaviour when the -S flag ("don't import site") is supplied to Python should be documented as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

1 participant