Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Refresh the venv introduction documentation, and correct the statement about VIRTUAL_ENV (GH-98350) #98350

Merged
merged 4 commits into from
Oct 19, 2022

Conversation

pelson
Copy link
Contributor

@pelson pelson commented Oct 17, 2022

Refresh the venv introduction documentation, and correct the incorrect statement about the VIRTUAL_ENV environment variable mentioned in #21970 (comment) in discussion with @vsajip.

This is quite an extensive restructure of the venv introduction. The existing documentation has clearly been developed iteratively, and it therefore needed a bit of effort to ensure that the information is presented logically and consistently. I am happy to adapt/adjust as requested, but I believe the proposed change is simpler, shorter and more precise.

In practice this documentation can be back-ported fully (it doesn't refer to any new features).

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Oct 17, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@pelson pelson force-pushed the enh/venv-docs branch 2 times, most recently from c11acb4 to 54259a2 Compare October 17, 2022 08:45
…orrect statement about the VIRTUAL_ENV environment variable
@vsajip
Copy link
Member

vsajip commented Oct 17, 2022

Thanks, Phil, your changes look good to me. I'll ask for an additional reviewer to look at it, since I may be a bit too close to it to notice things from a newcomer's perspective.

@vsajip vsajip requested a review from CAM-Gerlach October 17, 2022 10:15
@vsajip vsajip added docs Documentation in the Doc dir skip issue skip news labels Oct 17, 2022
Copy link
Member

@vsajip vsajip left a comment

Choose a reason for hiding this comment

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

Just a minor whitespace change.

be optionally isolated from the base's site packages, meaning
that packages installed in the base environment will not be accessible from
the virtual environment.
A virtual environment is therefore a powerful and convenient concept which
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps insert a blank line here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing. Done in 1ba4797

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@vsajip
Copy link
Member

vsajip commented Oct 17, 2022

Phil, you need to sign the CLA using the button above.

@CAM-Gerlach CAM-Gerlach added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Oct 17, 2022
Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

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

This is a significant improvement overall in the structure, presentation and phrasing of these docs. Thanks for all your work, @pelson !

I did have a number of comments, all as suggestions, that fix/clarify some key details, use appropriate Sphinx syntax, update or remove some outdated or inapplicable passages, say the same thing more simply and concisely, avoid repetition and improve phrasing.

To easily apply some or all of them with one click, go to the Files tab, clicking Add to batch on each of the suggestions, and finally click Commit once you've selected all the ones you want. You can also reply with your own suggestions and add/apply those at the same time, if you want to fix something in mine. That will apply the specific suggestions and auto-resolve the review comments all in one go, which makes things a lot easier for both you and us.

Thanks, and looking forward to seeing this merged!

Doc/library/venv.rst Outdated Show resolved Hide resolved
Doc/library/venv.rst Outdated Show resolved Hide resolved
Doc/library/venv.rst Outdated Show resolved Hide resolved
Doc/library/venv.rst Outdated Show resolved Hide resolved
Doc/library/venv.rst Outdated Show resolved Hide resolved
Doc/library/venv.rst Outdated Show resolved Hide resolved
Doc/library/venv.rst Outdated Show resolved Hide resolved
Doc/library/venv.rst Outdated Show resolved Hide resolved
Doc/library/venv.rst Outdated Show resolved Hide resolved
Comment on lines 130 to 136
.. note:: When a virtual environment is active, any options that change the
installation path will be ignored from all :mod:`distutils` configuration
files to prevent projects being inadvertently installed outside of the
virtual environment.


.. _venv-api:
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
.. note:: When a virtual environment is active, any options that change the
installation path will be ignored from all :mod:`distutils` configuration
files to prevent projects being inadvertently installed outside of the
virtual environment.
.. _venv-api:
.. _venv-api:

Distutils has been officially deprecated since Python 3.10 (the oldest backportable version) and removed in this version, 3.12 (thus the link should not resolve). Furthermore, use of these config files and use of distutils as an installer directly has been deprecated for perhaps a decade. Therefore, this should just be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The one thing that would make me hesitate with this one is that it would be good to get these improvements into older Python docs. The VIRTUAL_ENV environment variable documentation is wrong since Python 3.8 (by a commit that was backported that far 2 years ago).

Copy link
Member

Choose a reason for hiding this comment

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

But that snippet could be left out even in documentation for older Python versions, as it doesn't really add all that much information - for example, it's not clear which options might be meant in

any options that change the installation path

Copy link
Member

Choose a reason for hiding this comment

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

The one thing that would make me hesitate with this one is that it would be good to get these improvements into older Python docs.

Right, which is why I mentioned it has been deprecated since the oldest backportable version, Python 3.10, and discouraged for perhaps a decade (never mind "distutils configuration files"—I don't know if I've ever run into any modern mention of anything actually using them these days; I'm involved with a fair bit of packaging stuff and I'd never even heard of them until now). Ergo, this is likely to cause more confusion than anything, if even packaging experts like @vsajip aren't even sure what it is intended to mean. And if worst comes to worse, this one change can always be dropped in a backport (though it seems very unnecessary).

The VIRTUAL_ENV environment variable documentation is wrong since Python 3.8 (by a commit that was backported that far 2 years ago).

I'm not entirely sure what you intend to mean here, sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not entirely sure what you intend to mean here, sorry.

Simply stating that there is a factually incorrect statement in the documenation relating to VIRTUAL_ENV environment use (it claims: "This can be used to check if one is running inside a virtual environment.", which is wrong), which it would be great to remove from as many backported versions as possible to avoid incorrect usage in the wild.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, gotcha 👍 I was confused and wasn't sure the connection.

@CAM-Gerlach
Copy link
Member

As a quick reminder, to easily apply some or all of them with one click, go to the Files tab, clicking Add to batch on each of the suggestions, and finally click Commit once you've selected all the ones you want. You can also reply with your own suggestions and add/apply those at the same time, if you want to fix something in mine. That will apply the specific suggestions and auto-resolve the review comments all in one go, which makes things a lot easier for both you and us.

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
@miss-islington
Copy link
Contributor

Sorry, @pelson and @vsajip, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 1a6bacb31f7b49c244a6cc3ff0fa7f71a82412ef 3.10

@CAM-Gerlach
Copy link
Member

CAM-Gerlach commented Oct 19, 2022

Thanks @pelson for your hard work and putting up with me, and @vsajip for reviewing, inviting me to and merging!

@vsajip @pelson were either of you planning to do the manual cherry picking for the backport? If not, I can help take care of it, though I'm also pretty busy finishing #95913 before the 3.11 release Monday so it might not happen right away.

vsajip pushed a commit to vsajip/cpython that referenced this pull request Oct 19, 2022
…atement about VIRTUAL_ENV (pythonGH-98350)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
(cherry picked from commit 1a6bacb)
vsajip pushed a commit to vsajip/cpython that referenced this pull request Oct 19, 2022
… the statement about VIRTUAL_ENV (pythonGH-98350)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
(cherry picked from commit 1a6bacb)
@bedevere-bot
Copy link

GH-98465 is a backport of this pull request to the 3.11 branch.

@bedevere-bot
Copy link

GH-98466 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Oct 19, 2022
@vsajip
Copy link
Member

vsajip commented Oct 19, 2022

were either of you planning to do the manual cherry picking for the backport?

Yes, I've had a stab at it 🙂

@CAM-Gerlach
Copy link
Member

Thanks @vsajip !

@vsajip
Copy link
Member

vsajip commented Oct 20, 2022

I just looked at the built documentation and noticed something a bit odd.

ss82

I'm not familiar with the use of exclamation marks in this markup - :program:`!fish` and :program:`!csh` activation scripts. @CAM-Gerlach what do they do? I couldn't see anything in the Sphinx docs.

carljm added a commit to carljm/cpython that referenced this pull request Oct 20, 2022
* main: (40 commits)
  pythongh-98461: Fix source location in comprehensions bytecode (pythonGH-98464)
  pythongh-98421: Clean Up PyObject_Print (pythonGH-98422)
  pythongh-98360: multiprocessing now spawns children on Windows with correct argv[0] in virtual environments (pythonGH-98462)
  CODEOWNERS: Become a typing code owner (python#98480)
  [doc] Improve logging cookbook example. (pythonGH-98481)
  Add more tkinter.Canvas tests (pythonGH-98475)
  pythongh-95023: Added os.setns and os.unshare functions (python#95046)
  pythonGH-98363: Presize the list for batched() (pythonGH-98419)
  pythongh-98374: Suppress ImportError for invalid query for help() command. (pythongh-98450)
  typing tests: `_overload_dummy` raises `NotImplementedError`, not `RuntimeError` (python#98351)
  pythongh-98354: Add unicode check for 'name' attribute in _imp_create_builtin (pythonGH-98412)
  pythongh-98257: Make _PyEval_SetTrace() reentrant (python#98258)
  pythongh-98414: py.exe launcher does not use defaults for -V:company/ option (pythonGH-98460)
  pythongh-98417: Store int_max_str_digits on the Interpreter State (pythonGH-98418)
  Doc: Remove title text from internal links (python#98409)
  [doc] Refresh the venv introduction documentation, and correct the statement about VIRTUAL_ENV (pythonGH-98350)
  Docs: Bump sphinx-lint and fix unbalanced inline literal markup (python#98441)
  pythongh-92886: Replace assertion statements in `handlers.BaseHandler` to support running with optimizations (`-O`) (pythonGH-93231)
  pythongh-92886: Fix tests that fail when running with optimizations (`-O`) in `_test_multiprocessing.py` (pythonGH-93233)
  pythongh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_py_compile.py` (pythonGH-93235)
  ...
@CAM-Gerlach
Copy link
Member

As documented in at the top of the Sphinx Roles doc and in the Python devguide, for any Sphinx role that creates a cross-reference (which are most of them), most domain-specific Sphinx roles) prefixing the content of with ! disables resolving the reference.

This is used in the CPython docs when the target is already referenced within the same paragraph/information unit to not link the same thing multiple times, when referring to a class, function etc. within its own description to avoid linking to itself, and when either the target intentionally doesn't exist (e.g. example class, removed from Python, not part of CPython, deliberately undocumented, etc) to skip wasting time looking it up and silence the resulting spurious warning.

I had naturally assumed that :program: was a cross-reference role that referenced programs defined by the .. program:: directive, just like :option: does for the .. option:: directive (that can be embedded inside .. program::, and I needed a ! since those programs weren't defined within the Python docs. However, it seems the role is in fact currently only for semantics/formatting purposes, and it does not support cross referencing. Therefore, the ! can simply be elided.

@vsajip
Copy link
Member

vsajip commented Oct 21, 2022

TIL - thanks! I'll look at updating those at some point.

@CAM-Gerlach
Copy link
Member

Thanks! Since its my fault, I'll also look to take care of it at some point soon if you don't get to it first.

Also, I talked to Adam about adding cross-reference support to future Sphinx versions for :program:, so this might eventually work as intended.

@pelson pelson deleted the enh/venv-docs branch October 30, 2022 21:07
hugovk pushed a commit that referenced this pull request Mar 15, 2023
Remove the exclamation mark from :program:`!foo` in .rst files because
it inadvertently shows up in the rendered HTML.

(Sphinx's cross-referencing roles use a '!' prefix to suppress
hyperlinking[1], but :program: is not a cross-referencing role so the
'!' is displayed verbatim.)

The exclamation marks in venv.rst were introduced in #98350. See
comments [2] and [3] for additional discussion.

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-syntax
[2]: #98350 (comment)
[3]: #98350 (comment)

Reported-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
hugovk pushed a commit to hugovk/cpython that referenced this pull request Mar 15, 2023
Remove the exclamation mark from :program:`!foo` in .rst files because
it inadvertently shows up in the rendered HTML.

(Sphinx's cross-referencing roles use a '!' prefix to suppress
hyperlinking[1], but :program: is not a cross-referencing role so the
'!' is displayed verbatim.)

The exclamation marks in venv.rst were introduced in python#98350. See
comments [2] and [3] for additional discussion.

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-syntax
[2]: python#98350 (comment)
[3]: python#98350 (comment)

Reported-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
(cherry picked from commit 8647ba4)
hugovk added a commit to hugovk/cpython that referenced this pull request Mar 15, 2023
Remove the exclamation mark from :program:`!foo` in .rst files because
it inadvertently shows up in the rendered HTML.

(Sphinx's cross-referencing roles use a '!' prefix to suppress
hyperlinking[1], but :program: is not a cross-referencing role so the
'!' is displayed verbatim.)

The exclamation marks in venv.rst were introduced in pythonGH-98350. See
comments [2] and [3] for additional discussion.

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.htmlGH-cross-referencing-syntax
[2]: https://github.com/python/cpython/pull/98350GH-issuecomment-1285965759
[3]: https://github.com/python/cpython/pull/98350GH-issuecomment-1286394047

Reported-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>.
(cherry picked from commit 8647ba4)

Co-authored-by: Tom Levy <tomlevy93@gmail.com>
hugovk pushed a commit to hugovk/cpython that referenced this pull request Mar 15, 2023
Remove the exclamation mark from :program:`!foo` in .rst files because
it inadvertently shows up in the rendered HTML.

(Sphinx's cross-referencing roles use a '!' prefix to suppress
hyperlinking[1], but :program: is not a cross-referencing role so the
'!' is displayed verbatim.)

The exclamation marks in venv.rst were introduced in pythonGH-98350. See
comments [2] and [3] for additional discussion.

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.htmlGH-cross-referencing-syntax
[2]: https://github.com/python/cpython/pull/98350GH-issuecomment-1285965759
[3]: https://github.com/python/cpython/pull/98350GH-issuecomment-1286394047

Reported-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>.
(cherry picked from commit 8647ba4)

Co-authored-by: Tom Levy <tomlevy93@gmail.com>
hugovk pushed a commit to hugovk/cpython that referenced this pull request Mar 15, 2023
Remove the exclamation mark from :program:`!foo` in .rst files because
it inadvertently shows up in the rendered HTML.

(Sphinx's cross-referencing roles use a '!' prefix to suppress
hyperlinking[1], but :program: is not a cross-referencing role so the
'!' is displayed verbatim.)

The exclamation marks in venv.rst were introduced in pythonGH-98350. See
comments [2] and [3] for additional discussion.

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.htmlGH-cross-referencing-syntax
[2]: https://github.com/python/cpython/pull/98350GH-issuecomment-1285965759
[3]: https://github.com/python/cpython/pull/98350GH-issuecomment-1286394047

Reported-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>.
(cherry picked from commit 8647ba4)

Co-authored-by: Tom Levy <tomlevy93@gmail.com>
@tom93
Copy link
Contributor

tom93 commented Mar 15, 2023

Therefore, the ! can simply be elided.

Done in #102694.

hugovk added a commit that referenced this pull request Mar 15, 2023
…2716)

Remove the exclamation mark from :program:`!foo` in .rst files because
it inadvertently shows up in the rendered HTML.

(Sphinx's cross-referencing roles use a '!' prefix to suppress
hyperlinking[1], but :program: is not a cross-referencing role so the
'!' is displayed verbatim.)

The exclamation marks in venv.rst were introduced in #98350. See
comments [2] and [3] for additional discussion.

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-syntax
[2]: #98350 (comment)
[3]: #98350 (comment)

Reported-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Co-authored-by: Tom Levy <tomlevy93@gmail.com>
hugovk added a commit that referenced this pull request Mar 15, 2023
…2717)

Remove the exclamation mark from :program:`!foo` in .rst files because
it inadvertently shows up in the rendered HTML.

(Sphinx's cross-referencing roles use a '!' prefix to suppress
hyperlinking[1], but :program: is not a cross-referencing role so the
'!' is displayed verbatim.)

The exclamation marks in venv.rst were introduced in #98350. See
comments [2] and [3] for additional discussion.

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-syntax
[2]: #98350 (comment)
[3]: #98350 (comment)

Reported-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Co-authored-by: Tom Levy <tomlevy93@gmail.com>
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
Remove the exclamation mark from :program:`!foo` in .rst files because
it inadvertently shows up in the rendered HTML.

(Sphinx's cross-referencing roles use a '!' prefix to suppress
hyperlinking[1], but :program: is not a cross-referencing role so the
'!' is displayed verbatim.)

The exclamation marks in venv.rst were introduced in python#98350. See
comments [2] and [3] for additional discussion.

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-syntax
[2]: python#98350 (comment)
[3]: python#98350 (comment)

Reported-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
Remove the exclamation mark from :program:`!foo` in .rst files because
it inadvertently shows up in the rendered HTML.

(Sphinx's cross-referencing roles use a '!' prefix to suppress
hyperlinking[1], but :program: is not a cross-referencing role so the
'!' is displayed verbatim.)

The exclamation marks in venv.rst were introduced in python#98350. See
comments [2] and [3] for additional discussion.

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-syntax
[2]: python#98350 (comment)
[3]: python#98350 (comment)

Reported-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants