Skip to content

Commit eb62274

Browse files
[3.8] Touch up venv docs (pythonGH-14922) (pythonGH-14923)
(cherry picked from commit 2f224a0) Co-authored-by: Brett Cannon <54418+brettcannon@users.noreply.github.com> Automerge-Triggered-By: @brettcannon
1 parent 9d54de1 commit eb62274

1 file changed

Lines changed: 26 additions & 21 deletions

File tree

Doc/library/venv.rst

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Creating virtual environments
4747
A virtual environment is a directory tree which contains Python executable
4848
files and other files which indicate that it is a virtual environment.
4949

50-
Common installation tools such as ``Setuptools`` and ``pip`` work as
50+
Common installation tools such as setuptools_ and pip_ work as
5151
expected with virtual environments. In other words, when a virtual
5252
environment is active, they install Python packages into the virtual
5353
environment without needing to be told to do so explicitly.
@@ -64,24 +64,25 @@ Creating virtual environments
6464
Python installation).
6565

6666
When a virtual environment is active, any options that change the
67-
installation path will be ignored from all distutils configuration files to
68-
prevent projects being inadvertently installed outside of the virtual
69-
environment.
67+
installation path will be ignored from all :mod:`distutils` configuration
68+
files to prevent projects being inadvertently installed outside of the
69+
virtual environment.
7070

7171
When working in a command shell, users can make a virtual environment active
7272
by running an ``activate`` script in the virtual environment's executables
73-
directory (the precise filename is shell-dependent), which prepends the
74-
virtual environment's directory for executables to the ``PATH`` environment
75-
variable for the running shell. There should be no need in other
76-
circumstances to activate a virtual environment—scripts installed into
77-
virtual environments have a "shebang" line which points to the virtual
78-
environment's Python interpreter. This means that the script will run with
79-
that interpreter regardless of the value of ``PATH``. On Windows, "shebang"
80-
line processing is supported if you have the Python Launcher for Windows
81-
installed (this was added to Python in 3.3 - see :pep:`397` for more
82-
details). Thus, double-clicking an installed script in a Windows Explorer
83-
window should run the script with the correct interpreter without there
84-
needing to be any reference to its virtual environment in ``PATH``.
73+
directory (the precise filename and command to use the file is
74+
shell-dependent), which prepends the virtual environment's directory for
75+
executables to the ``PATH`` environment variable for the running shell. There
76+
should be no need in other circumstances to activate a virtual
77+
environment; scripts installed into virtual environments have a "shebang"
78+
line which points to the virtual environment's Python interpreter. This means
79+
that the script will run with that interpreter regardless of the value of
80+
``PATH``. On Windows, "shebang" line processing is supported if you have the
81+
Python Launcher for Windows installed (this was added to Python in 3.3 - see
82+
:pep:`397` for more details). Thus, double-clicking an installed script in a
83+
Windows Explorer window should run the script with the correct interpreter
84+
without there needing to be any reference to its virtual environment in
85+
``PATH``.
8586

8687

8788
.. _venv-api:
@@ -130,20 +131,20 @@ creation according to their needs, the :class:`EnvBuilder` class.
130131
Added the ``prompt`` parameter
131132

132133
Creators of third-party virtual environment tools will be free to use the
133-
provided ``EnvBuilder`` class as a base class.
134+
provided :class:`EnvBuilder` class as a base class.
134135

135136
The returned env-builder is an object which has a method, ``create``:
136137

137138
.. method:: create(env_dir)
138139

139-
This method takes as required argument the path (absolute or relative to
140-
the current directory) of the target directory which is to contain the
140+
Create a virtual environment by specifying the target directory
141+
(absolute or relative to the current directory) which is to contain the
141142
virtual environment. The ``create`` method will either create the
142143
environment in the specified directory, or raise an appropriate
143144
exception.
144145

145-
The ``create`` method of the ``EnvBuilder`` class illustrates the hooks
146-
available for subclass customization::
146+
The ``create`` method of the :class:`EnvBuilder` class illustrates the
147+
hooks available for subclass customization::
147148

148149
def create(self, env_dir):
149150
"""
@@ -471,3 +472,7 @@ subclass which installs setuptools and pip into a created virtual environment::
471472

472473
This script is also available for download `online
473474
<https://gist.github.com/vsajip/4673395>`_.
475+
476+
477+
.. _setuptools: https://pypi.org/project/setuptools/
478+
.. _pip: https://pypi.org/project/pip/

0 commit comments

Comments
 (0)