Skip to content

Commit 6630ec3

Browse files
authored
Merge pull request #9718 from pradyunsg/docs/rename-reference-to-commands
2 parents f95ff05 + 3fe1954 commit 6630ec3

31 files changed

+2763
-2571
lines changed

docs/html/cli/index.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Commands
2+
3+
The general options that apply to all the commands listed below can be
4+
found [under the `pip` page in this section](pip).
5+
6+
```{toctree}
7+
:maxdepth: 1
8+
:hidden:
9+
10+
pip
11+
```
12+
13+
```{toctree}
14+
:maxdepth: 1
15+
:caption: Environment Management and Introspection
16+
17+
pip_install
18+
pip_uninstall
19+
pip_list
20+
pip_freeze
21+
pip_check
22+
```
23+
24+
```{toctree}
25+
:maxdepth: 1
26+
:caption: Handling Distribution Files
27+
28+
pip_download
29+
pip_wheel
30+
pip_hash
31+
```
32+
33+
```{toctree}
34+
:maxdepth: 1
35+
:caption: Package Index information
36+
37+
pip_show
38+
pip_search
39+
```
40+
41+
```{toctree}
42+
:maxdepth: 1
43+
:caption: Managing pip itself
44+
45+
pip_cache
46+
pip_config
47+
pip_debug
48+
```

docs/html/cli/pip.rst

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
===
2+
pip
3+
===
4+
5+
6+
Usage
7+
*****
8+
9+
.. tab:: Unix/macOS
10+
11+
.. code-block:: shell
12+
13+
python -m pip <command> [options]
14+
15+
.. tab:: Windows
16+
17+
.. code-block:: shell
18+
19+
py -m pip <command> [options]
20+
21+
Description
22+
***********
23+
24+
25+
.. _`Logging`:
26+
27+
28+
Logging
29+
=======
30+
31+
Console logging
32+
~~~~~~~~~~~~~~~
33+
34+
pip offers :ref:`-v, --verbose <--verbose>` and :ref:`-q, --quiet <--quiet>`
35+
to control the console log level. By default, some messages (error and warnings)
36+
are colored in the terminal. If you want to suppress the colored output use
37+
:ref:`--no-color <--no-color>`.
38+
39+
40+
.. _`FileLogging`:
41+
42+
File logging
43+
~~~~~~~~~~~~
44+
45+
pip offers the :ref:`--log <--log>` option for specifying a file where a maximum
46+
verbosity log will be kept. This option is empty by default. This log appends
47+
to previous logging.
48+
49+
Like all pip options, ``--log`` can also be set as an environment variable, or
50+
placed into the pip config file. See the :ref:`Configuration` section.
51+
52+
.. _`exists-action`:
53+
54+
--exists-action option
55+
======================
56+
57+
This option specifies default behavior when path already exists.
58+
Possible cases: downloading files or checking out repositories for installation,
59+
creating archives. If ``--exists-action`` is not defined, pip will prompt
60+
when decision is needed.
61+
62+
*(s)witch*
63+
Only relevant to VCS checkout. Attempt to switch the checkout
64+
to the appropriate URL and/or revision.
65+
*(i)gnore*
66+
Abort current operation (e.g. don't copy file, don't create archive,
67+
don't modify a checkout).
68+
*(w)ipe*
69+
Delete the file or VCS checkout before trying to create, download, or checkout a new one.
70+
*(b)ackup*
71+
Rename the file or checkout to ``{name}{'.bak' * n}``, where n is some number
72+
of ``.bak`` extensions, such that the file didn't exist at some point.
73+
So the most recent backup will be the one with the largest number after ``.bak``.
74+
*(a)abort*
75+
Abort pip and return non-zero exit status.
76+
77+
.. _`build-interface`:
78+
79+
80+
Build System Interface
81+
======================
82+
83+
pip builds packages by invoking the build system. By default, builds will use
84+
``setuptools``, but if a project specifies a different build system using a
85+
``pyproject.toml`` file, as per :pep:`517`, pip will use that instead. As well
86+
as package building, the build system is also invoked to install packages
87+
direct from source. This is handled by invoking the build system to build a
88+
wheel, and then installing from that wheel. The built wheel is cached locally
89+
by pip to avoid repeated identical builds.
90+
91+
The current interface to the build system is via the ``setup.py`` command line
92+
script - all build actions are defined in terms of the specific ``setup.py``
93+
command line that will be run to invoke the required action.
94+
95+
Setuptools Injection
96+
~~~~~~~~~~~~~~~~~~~~
97+
98+
When :pep:`517` is not used, the supported build system is ``setuptools``.
99+
However, not all packages use ``setuptools`` in their build scripts. To support
100+
projects that use "pure ``distutils``", pip injects ``setuptools`` into
101+
``sys.modules`` before invoking ``setup.py``. The injection should be
102+
transparent to ``distutils``-based projects, but 3rd party build tools wishing
103+
to provide a ``setup.py`` emulating the commands pip requires may need to be
104+
aware that it takes place.
105+
106+
Projects using :pep:`517` *must* explicitly use setuptools - pip does not do
107+
the above injection process in this case.
108+
109+
Build System Output
110+
~~~~~~~~~~~~~~~~~~~
111+
112+
Any output produced by the build system will be read by pip (for display to the
113+
user if requested). In order to correctly read the build system output, pip
114+
requires that the output is written in a well-defined encoding, specifically
115+
the encoding the user has configured for text output (which can be obtained in
116+
Python using ``locale.getpreferredencoding``). If the configured encoding is
117+
ASCII, pip assumes UTF-8 (to account for the behaviour of some Unix systems).
118+
119+
Build systems should ensure that any tools they invoke (compilers, etc) produce
120+
output in the correct encoding. In practice - and in particular on Windows,
121+
where tools are inconsistent in their use of the "OEM" and "ANSI" codepages -
122+
this may not always be possible. pip will therefore attempt to recover cleanly
123+
if presented with incorrectly encoded build tool output, by translating
124+
unexpected byte sequences to Python-style hexadecimal escape sequences
125+
(``"\x80\xff"``, etc). However, it is still possible for output to be displayed
126+
using an incorrect encoding (mojibake).
127+
128+
Under :pep:`517`, handling of build tool output is the backend's responsibility,
129+
and pip simply displays the output produced by the backend. (Backends, however,
130+
will likely still have to address the issues described above).
131+
132+
PEP 517 and 518 Support
133+
~~~~~~~~~~~~~~~~~~~~~~~
134+
135+
As of version 10.0, pip supports projects declaring dependencies that are
136+
required at install time using a ``pyproject.toml`` file, in the form described
137+
in :pep:`518`. When building a project, pip will install the required
138+
dependencies locally, and make them available to the build process.
139+
Furthermore, from version 19.0 onwards, pip supports projects specifying the
140+
build backend they use in ``pyproject.toml``, in the form described in
141+
:pep:`517`.
142+
143+
When making build requirements available, pip does so in an *isolated
144+
environment*. That is, pip does not install those requirements into the user's
145+
``site-packages``, but rather installs them in a temporary directory which it
146+
adds to the user's ``sys.path`` for the duration of the build. This ensures
147+
that build requirements are handled independently of the user's runtime
148+
environment. For example, a project that needs a recent version of setuptools
149+
to build can still be installed, even if the user has an older version
150+
installed (and without silently replacing that version).
151+
152+
In certain cases, projects (or redistributors) may have workflows that
153+
explicitly manage the build environment. For such workflows, build isolation
154+
can be problematic. If this is the case, pip provides a
155+
``--no-build-isolation`` flag to disable build isolation. Users supplying this
156+
flag are responsible for ensuring the build environment is managed
157+
appropriately (including ensuring that all required build dependencies are
158+
installed).
159+
160+
By default, pip will continue to use the legacy (direct ``setup.py`` execution
161+
based) build processing for projects that do not have a ``pyproject.toml`` file.
162+
Projects with a ``pyproject.toml`` file will use a :pep:`517` backend. Projects
163+
with a ``pyproject.toml`` file, but which don't have a ``build-system`` section,
164+
will be assumed to have the following backend settings::
165+
166+
[build-system]
167+
requires = ["setuptools>=40.8.0", "wheel"]
168+
build-backend = "setuptools.build_meta:__legacy__"
169+
170+
.. note::
171+
172+
``setuptools`` 40.8.0 is the first version of setuptools that offers a
173+
:pep:`517` backend that closely mimics directly executing ``setup.py``.
174+
175+
If a project has ``[build-system]``, but no ``build-backend``, pip will also use
176+
``setuptools.build_meta:__legacy__``, but will expect the project requirements
177+
to include ``setuptools`` and ``wheel`` (and will report an error if the
178+
installed version of ``setuptools`` is not recent enough).
179+
180+
If a user wants to explicitly request :pep:`517` handling even though a project
181+
doesn't have a ``pyproject.toml`` file, this can be done using the
182+
``--use-pep517`` command line option. Similarly, to request legacy processing
183+
even though ``pyproject.toml`` is present, the ``--no-use-pep517`` option is
184+
available (although obviously it is an error to choose ``--no-use-pep517`` if
185+
the project has no ``setup.py``, or explicitly requests a build backend). As
186+
with other command line flags, pip recognises the ``PIP_USE_PEP517``
187+
environment veriable and a ``use-pep517`` config file option (set to true or
188+
false) to set this option globally. Note that overriding pip's choice of
189+
whether to use :pep:`517` processing in this way does *not* affect whether pip
190+
will use an isolated build environment (which is controlled via
191+
``--no-build-isolation`` as noted above).
192+
193+
Except in the case noted above (projects with no :pep:`518` ``[build-system]``
194+
section in ``pyproject.toml``), pip will never implicitly install a build
195+
system. Projects **must** ensure that the correct build system is listed in
196+
their ``requires`` list (this applies even if pip assumes that the
197+
``setuptools`` backend is being used, as noted above).
198+
199+
.. _pep-518-limitations:
200+
201+
**Historical Limitations**:
202+
203+
* ``pip<18.0``: only supports installing build requirements from wheels, and
204+
does not support the use of environment markers and extras (only version
205+
specifiers are respected).
206+
207+
* ``pip<18.1``: build dependencies using .pth files are not properly supported;
208+
as a result namespace packages do not work under Python 3.2 and earlier.
209+
210+
Future Developments
211+
~~~~~~~~~~~~~~~~~~~
212+
213+
:pep:`426` notes that the intention is to add hooks to project metadata in
214+
version 2.1 of the metadata spec, to explicitly define how to build a project
215+
from its source. Once this version of the metadata spec is final, pip will
216+
migrate to using that interface. At that point, the ``setup.py`` interface
217+
documented here will be retained solely for legacy purposes, until projects
218+
have migrated.
219+
220+
Specifically, applications should *not* expect to rely on there being any form
221+
of backward compatibility guarantees around the ``setup.py`` interface.
222+
223+
224+
Build Options
225+
~~~~~~~~~~~~~
226+
227+
The ``--global-option`` and ``--build-option`` arguments to the ``pip install``
228+
and ``pip wheel`` inject additional arguments into the ``setup.py`` command
229+
(``--build-option`` is only available in ``pip wheel``). These arguments are
230+
included in the command as follows:
231+
232+
.. tab:: Unix/macOS
233+
234+
.. code-block:: console
235+
236+
python setup.py <global_options> BUILD COMMAND <build_options>
237+
238+
.. tab:: Windows
239+
240+
.. code-block:: shell
241+
242+
py setup.py <global_options> BUILD COMMAND <build_options>
243+
244+
The options are passed unmodified, and presently offer direct access to the
245+
distutils command line. Use of ``--global-option`` and ``--build-option``
246+
should be considered as build system dependent, and may not be supported in the
247+
current form if support for alternative build systems is added to pip.
248+
249+
250+
.. _`General Options`:
251+
252+
General Options
253+
***************
254+
255+
.. pip-general-options::

docs/html/cli/pip_cache.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
.. _`pip cache`:
3+
4+
pip cache
5+
---------
6+
7+
8+
Usage
9+
*****
10+
11+
.. tab:: Unix/macOS
12+
13+
.. pip-command-usage:: cache "python -m pip"
14+
15+
.. tab:: Windows
16+
17+
.. pip-command-usage:: cache "py -m pip"
18+
19+
Description
20+
***********
21+
22+
.. pip-command-description:: cache
23+
24+
Options
25+
*******
26+
27+
.. pip-command-options:: cache

0 commit comments

Comments
 (0)