[New-bugs-announce] [issue33456] site.py: by default, a virtual environment is *not* isolated from the system-level site-packages directories

Lukas Waymann report at bugs.python.org
Thu May 10 10:57:34 EDT 2018


New submission from Lukas Waymann <meribold at gmail.com>:

PEP 405 says this:

> By default, a virtual environment is entirely isolated from the system-level site-packages directories.
>
> If the pyvenv.cfg file also contains a key include-system-site-packages with a value of true (not case sensitive), the site module will also add the system site directories to sys.path after the virtual environment site directories.

The documentation of the site module (https://docs.python.org/3/library/site.html) says (emphasis added):

> If pyvenv.cfg […] contains the key include-system-site-packages set to anything other than false (case-insensitive), the system-level prefixes will still also be searched for site-packages; *otherwise they won’t*.

However, what actually happens in site.py is different: see <https://github.com/python/cpython/blob/3.6/Lib/site.py#L447>.  The system_site variable is initialized to "true" and doesn't change unless the key include-system-site-packages exists in pyvenv.cfg.

I think system_site should be initialized to "false" and the condition in line 468 should be `if system_site.lower() != "false"`.

----------
components: Library (Lib)
messages: 316367
nosy: meribold
priority: normal
severity: normal
status: open
title: site.py: by default, a virtual environment is *not* isolated from the system-level site-packages directories
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33456>
_______________________________________


More information about the New-bugs-announce mailing list