classification
Title: site.py: by default, a virtual environment is *not* isolated from the system-level site-packages directories
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: cheryl.sabella, docs@python, meribold, vinay.sajip
Priority: normal Keywords: patch

Created on 2018-05-10 14:57 by meribold, last changed 2019-04-09 07:30 by vinay.sajip. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6755 merged meribold, 2018-05-10 15:30
Messages (2)
msg316367 - (view) Author: Lukas Waymann (meribold) * Date: 2018-05-10 14:57
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"`.
msg339711 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2019-04-09 07:27
New changeset c324c748871804f31f56b3bd02a8650b3bf1bae7 by Vinay Sajip (Lukas Waymann) in branch 'master':
bpo-33456: site module documentation - fix wrong default for key in pyvenv.cfg (GH-6755)
https://github.com/python/cpython/commit/c324c748871804f31f56b3bd02a8650b3bf1bae7
History
Date User Action Args
2019-04-09 07:30:51vinay.sajipsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-04-09 07:27:40vinay.sajipsetmessages: + msg339711
2019-04-08 21:48:35cheryl.sabellasetnosy: + vinay.sajip, cheryl.sabella, docs@python

assignee: docs@python
components: + Documentation, - Library (Lib)
versions: - Python 3.6
2018-05-10 15:30:46meriboldsetkeywords: + patch
stage: patch review
pull_requests: + pull_request6442
2018-05-10 14:57:34meriboldcreate