Repository navigation
Conversation
| * ``include-system-site-packages``: When ``true``, the ``site`` module will | ||
| also add the system site directories to ``sys.path`` after the virtual | ||
| environment site directories. If ``false``, the system site directories are | ||
| not included. Defaults to ``true``. |
There was a problem hiding this comment.
This true seems incorrect. PEP 405 says "By default, a virtual environment is entirely isolated from the system-level site-packages directories."
There was a problem hiding this comment.
There seems to be a CPython implementation thing where the key being absent makes it mean true, but it looks to me like the default should be false here.
EDIT: if changed, the History section needs the same edit
There was a problem hiding this comment.
PEP 405 is wrong, as you said CPython defaults to true and so tools treat it as such. The history entry for that correction I already added.
There was a problem hiding this comment.
Hmm, did some digging. Looks like this was a bug in the original implementation in 2012 (this CPython commit) and then in 2018 when that bug was reported in python/cpython#6755, the response was that there was no need to change the implementation or PEP 405. So okay, I guess we're fine here.
That said, I think this is still confusing: what is described is the behavior when the key is absent. However, the default when a new venv is created by the venv module is still the opposite: then pyvenv.cfg will contain: include-system-site-packages = false. So I suggest a rephrasing like this:
If this key is absent, it defaults to true. The standard-library venv module explicitly writes false unless --system-site-packages is requested.
All other tools I checked (virtualenv, uv, Poetry, Pipenv, Hatch) also explicitly write out false. It's annoying that this key is optional; it'd be better to make it required because there is zero reason to keep it optional. Not sure if we want to fix this now, leave it with this clarification, or perhaps add a "RECOMMENDED for tools to explicitly write false".
There was a problem hiding this comment.
Thanks, that looks clear to me now. I will leave this comment thread unresolved for now; another reviewer may want to see it.
rgommers
left a comment
There was a problem hiding this comment.
LGTM now, thanks @konstin. I think this improves the specification in both clarity and in fixing the historical error that was still present in PEP 405. Happy for this to go in; I'll leave it open for at least a few days because it touches Specifications, so useful for a second pair of eyes to check it.
Cleanup ahead of PEP 838.
pyvenv.cfginclude-system-site-packagesdefaults totrueI left the parts that were previously vague as such, only removing those that are vague and misleading.
📚 Documentation preview 📚: https://python-packaging-user-guide--2201.org.readthedocs.build/en/2201/