Skip to content

Conversation

pppppkun
Copy link

@pppppkun pppppkun commented Oct 8, 2024

Based on the discussion here: #82419 and advises from the @tiran and @encukou , I further clarified the relationship between ENABLE_USER_SITE and the functions getusersitepackages() and getuserbase() in the document. I also added a method to configure the output of these two functions.


📚 Documentation preview 📚: https://cpython-previews--125083.org.readthedocs.build/

@ghost
Copy link

ghost commented Oct 8, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news awaiting review labels Oct 8, 2024
@merwok merwok changed the title gh-82419: Refactor site.rst to clarify user site-packages disabling gh-82419: Improve site docs to clarify user site-packages disabling Oct 8, 2024
:envvar:`PYTHONNOUSERSITE`). ``None`` means it was disabled for security
reasons (mismatch between user or group id and effective id) or by an
administrator.
administrator. Note that :func:`getusersitepackages` and :func:`getuserbase`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s add some breathing space:

Suggested change
administrator. Note that :func:`getusersitepackages` and :func:`getuserbase`
administrator.
Note that :func:`getusersitepackages` and :func:`getuserbase`

administrator.
administrator. Note that :func:`getusersitepackages` and :func:`getuserbase`
don't take this variable into account. The check for :data:`ENABLE_USER_SITE` and
modification of ``sys.path`` occurs later. To disable user site-packages,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
modification of ``sys.path`` occurs later. To disable user site-packages,
modification of ``sys.path`` occur later. To disable user site-packages,

(two things occur)

don't take this variable into account. The check for :data:`ENABLE_USER_SITE` and
modification of ``sys.path`` occurs later. To disable user site-packages,
users are encouraged to create :mod:`sitecustomize` or :mod:`usercustomize`,
rather than try to edit :file:`Lib/site.py`. Changing :file:`Lib/site.py`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should refer to the site module, not to the Lib/site.py file that only exists with that name in cpython repo, not after installation 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe something like: rather than try to edit site.py to make it clear we’re talking about the file, not the module (which is something living in the memory of a python interpreter)

users are encouraged to create :mod:`sitecustomize` or :mod:`usercustomize`,
rather than try to edit :file:`Lib/site.py`. Changing :file:`Lib/site.py`
won't work unless recompile Python, but administrators should still be able
to set :data:`ENABLE_USER_SITE` in a :mod:`sitecustomize` module.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would delete that last sentence, it repeats info.

@pppppkun
Copy link
Author

pppppkun commented Oct 9, 2024

@merwok Thank you for your feedback, I will revise it later.

@merwok merwok requested review from encukou and tiran October 9, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants