This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: site.py reporting user site info even if ENABLE_USER_SITE=False
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: bjmuld, christian.heimes
Priority: normal Keywords: patch

Created on 2019-09-20 19:34 by bjmuld, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 16303 closed bjmuld, 2019-09-20 19:35
Messages (2)
msg352884 - (view) Author: Barry Muldrey (bjmuld) * Date: 2019-09-20 19:34
site info is accessed externally via getusersitepackages() and getuserbase()... for example see "pip/_internal/locations.py"

If ENABLE_USER_SITE is set to "False," or otherwise disabled,
accesses to these methods should return '' or None (shouldn't they?).

Currently, I have ENABLE_USER_SITE globally disabled (by various means), but pip's call to getusersitepackages() is still returning "~/.local/lib/...".

This seems wrong.  An alternative would be for external tools to manually import site.ENABLE_USER_SITE, but this seems incorrect.
msg353008 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-09-23 10:58
getusersitepackages() and getuserbase() don't take ENABLE_USER_SITE into account. The function simply return the location of the user site-package directory independently of the value of ENABLE_USER_SITE. The check for ENABLE_USER_SITE and modification of sys.path occurs later. The design allows applications to get the hypothetical path for user site-packages independently from the ENABLE_USER_SITE flag.

The API is mature, old, and around since Python 2.6. We can't change it without breaking backwards compatibility.
History
Date User Action Args
2022-04-11 14:59:20adminsetgithub: 82419
2019-09-23 10:58:24christian.heimessetnosy: + christian.heimes
messages: + msg353008
2019-09-20 19:35:13bjmuldsetkeywords: + patch
stage: patch review
pull_requests: + pull_request15888
2019-09-20 19:34:35bjmuldcreate