Skip to content

Commit

Permalink
bpo-41376: Fix the documentation of site.getusersitepackages() (pyt…
Browse files Browse the repository at this point in the history
…honGH-21602)

`site.getusersitepackages()` returns the location of the user-specific site-packages directory
even when the user-specific site-packages is disabled.

```
$ python -s -m site
sys.path = [
    '/home/user/conda/lib/python37.zip',
    '/home/user/conda/lib/python3.7',
    '/home/user/conda/lib/python3.7/lib-dynload',
    '/home/user/conda/lib/python3.7/site-packages',
]
USER_BASE: '/home/user/.local' (exists)
USER_SITE: '/home/user/.local/lib/python3.7/site-packages' (doesn't exist)
ENABLE_USER_SITE: False
```

It was not practical to prevent the function from returning None if user-specific site-packages are disabled, since there are other uses of the function which are relying on this behaviour (e.g. `python -m site`).
  • Loading branch information
pelson authored Oct 8, 2020
1 parent 4e0ce82 commit 35f041d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Doc/library/site.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ Module contents

Return the path of the user-specific site-packages directory,
:data:`USER_SITE`. If it is not initialized yet, this function will also set
it, respecting :envvar:`PYTHONNOUSERSITE` and :data:`USER_BASE`.
it, respecting :data:`USER_BASE`. To determine if the user-specific
site-packages was added to ``sys.path`` :data:`ENABLE_USER_SITE` should be
used.

.. versionadded:: 3.2

Expand Down

0 comments on commit 35f041d

Please sign in to comment.