Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ac7a89

Browse files
committed
#17325: Improve distutils PyPI documentation.
Patch by Chris Jerdonek.
1 parent 90f7afd commit 2ac7a89

1 file changed

Lines changed: 90 additions & 56 deletions

File tree

Doc/distutils/packageindex.rst

Lines changed: 90 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,57 @@
88
The Python Package Index (PyPI)
99
*******************************
1010

11-
The `Python Package Index (PyPI)`_ holds :ref:`meta-data <meta-data>`
11+
The `Python Package Index (PyPI)`_ stores :ref:`meta-data <meta-data>`
1212
describing distributions packaged with distutils, as well as package data like
13-
distribution files if the package author wishes.
13+
distribution files if a package author wishes.
14+
15+
Distutils provides the :command:`register` and :command:`upload` commands for
16+
pushing meta-data and distribution files to PyPI, respectively. See
17+
:ref:`package-commands` for information on these commands.
18+
19+
20+
PyPI overview
21+
=============
22+
23+
PyPI lets you submit any number of versions of your distribution to the index.
24+
If you alter the meta-data for a particular version, you can submit it again
25+
and the index will be updated.
26+
27+
PyPI holds a record for each (name, version) combination submitted. The first
28+
user to submit information for a given name is designated the Owner of that
29+
name. Changes can be submitted through the :command:`register` command or
30+
through the web interface. Owners can designate other users as Owners or
31+
Maintainers. Maintainers can edit the package information, but not designate
32+
new Owners or Maintainers.
33+
34+
By default PyPI displays only the newest version of a given package. The web
35+
interface lets one change this default behavior and manually select which
36+
versions to display and hide.
37+
38+
For each version, PyPI displays a home page. The home page is created from
39+
the ``long_description`` which can be submitted via the :command:`register`
40+
command. See :ref:`package-display` for more information.
41+
42+
43+
.. _package-commands:
44+
45+
Distutils commands
46+
==================
1447

1548
Distutils exposes two commands for submitting package data to PyPI: the
1649
:ref:`register <package-register>` command for submitting meta-data to PyPI
1750
and the :ref:`upload <package-upload>` command for submitting distribution
18-
files. Both commands read configuration data from a special file called the
19-
:ref:`.pypirc file <pypirc>`. PyPI :ref:`displays a home page
20-
<package-display>` for each package created from the ``long_description``
21-
submitted by the :command:`register` command.
51+
files. Both commands read configuration data from a special file called a
52+
:ref:`.pypirc file <pypirc>`.
2253

2354

2455
.. _package-register:
2556

26-
Registering Packages
27-
====================
57+
The ``register`` command
58+
------------------------
2859

2960
The distutils command :command:`register` is used to submit your distribution's
30-
meta-data to the index. It is invoked as follows::
61+
meta-data to an index server. It is invoked as follows::
3162

3263
python setup.py register
3364

@@ -42,7 +73,8 @@ Distutils will respond with the following prompt::
4273
Your selection [default 1]:
4374

4475
Note: if your username and password are saved locally, you will not see this
45-
menu.
76+
menu. Also, refer to :ref:`pypirc` for how to store your credentials in a
77+
:file:`.pypirc` file.
4678

4779
If you have not registered with PyPI, then you will need to do so now. You
4880
should choose option 2, and enter your details as required. Soon after
@@ -53,26 +85,13 @@ Once you are registered, you may choose option 1 from the menu. You will be
5385
prompted for your PyPI username and password, and :command:`register` will then
5486
submit your meta-data to the index.
5587

56-
You may submit any number of versions of your distribution to the index. If you
57-
alter the meta-data for a particular version, you may submit it again and the
58-
index will be updated.
59-
60-
PyPI holds a record for each (name, version) combination submitted. The first
61-
user to submit information for a given name is designated the Owner of that
62-
name. They may submit changes through the :command:`register` command or through
63-
the web interface. They may also designate other users as Owners or Maintainers.
64-
Maintainers may edit the package information, but not designate other Owners or
65-
Maintainers.
66-
67-
By default PyPI displays only the newest version of a given package. The web
68-
interface lets one change this default behavior and manually select which
69-
versions to display and hide.
88+
See :ref:`package-cmdoptions` for options to the :command:`register` command.
7089

7190

7291
.. _package-upload:
7392

74-
Uploading Packages
75-
==================
93+
The ``upload`` command
94+
----------------------
7695

7796
The distutils command :command:`upload` pushes the distribution files to PyPI.
7897

@@ -86,29 +105,42 @@ PyPI. Note that these will be uploaded even if they are built using an earlier
86105
invocation of :file:`setup.py`, but that only distributions named on the command
87106
line for the invocation including the :command:`upload` command are uploaded.
88107

89-
The :command:`upload` command uses the username, password, and repository URL
90-
from the :file:`$HOME/.pypirc` file (see section :ref:`pypirc` for more on this
91-
file). If a :command:`register` command was previously called in the same command,
108+
If a :command:`register` command was previously called in the same command,
92109
and if the password was entered in the prompt, :command:`upload` will reuse the
93-
entered password. This is useful if you do not want to store a clear text
94-
password in the :file:`$HOME/.pypirc` file.
95-
96-
You can specify another PyPI server with the ``--repository=url`` option::
97-
98-
python setup.py sdist bdist_wininst upload -r http://example.com/pypi
99-
100-
See section :ref:`pypirc` for more on defining several servers.
110+
entered password. This is useful if you do not want to store a password in
111+
clear text in a :file:`.pypirc` file.
101112

102113
You can use the ``--sign`` option to tell :command:`upload` to sign each
103114
uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must
104115
be available for execution on the system :envvar:`PATH`. You can also specify
105116
which key to use for signing using the ``--identity=name`` option.
106117

107-
Other :command:`upload` options include ``--repository=url`` or
108-
``--repository=section`` where *url* is the url of the server and
109-
*section* the name of the section in :file:`$HOME/.pypirc`, and
110-
``--show-response`` (which displays the full response text from the PyPI
111-
server for help in debugging upload problems).
118+
See :ref:`package-cmdoptions` for additional options to the :command:`upload`
119+
command.
120+
121+
122+
.. _package-cmdoptions:
123+
124+
Additional command options
125+
--------------------------
126+
127+
This section describes options common to both the :command:`register` and
128+
:command:`upload` commands.
129+
130+
The ``--repository`` or ``-r`` option lets you specify a PyPI server
131+
different from the default. For example::
132+
133+
python setup.py sdist bdist_wininst upload -r https://example.com/pypi
134+
135+
For convenience, a name can be used in place of the URL when the
136+
:file:`.pypirc` file is configured to do so. For example::
137+
138+
python setup.py register -r other
139+
140+
See :ref:`pypirc` for more information on defining alternate servers.
141+
142+
The ``--show-response`` option displays the full response text from the PyPI
143+
server, which is useful when debugging problems with registering and uploading.
112144

113145

114146
.. index::
@@ -117,10 +149,14 @@ server for help in debugging upload problems).
117149

118150
.. _pypirc:
119151

120-
The .pypirc file
121-
================
152+
The ``.pypirc`` file
153+
--------------------
122154

123-
The format of the :file:`.pypirc` file is as follows::
155+
The :command:`register` and :command:`upload` commands both check for the
156+
existence of a :file:`.pypirc` file at the location :file:`$HOME/.pypirc`.
157+
If this file exists, the command uses the username, password, and repository
158+
URL configured in the file. The format of a :file:`.pypirc` file is as
159+
follows::
124160

125161
[distutils]
126162
index-servers =
@@ -137,7 +173,7 @@ name of all sections describing a repository.
137173
Each section describing a repository defines three variables:
138174

139175
- *repository*, that defines the url of the PyPI server. Defaults to
140-
``http://www.python.org/pypi``.
176+
``https://www.python.org/pypi``.
141177
- *username*, which is the registered username on the PyPI server.
142178
- *password*, that will be used to authenticate. If omitted the user
143179
will be prompt to type it when needed.
@@ -156,19 +192,17 @@ listed in the *index-servers* variable::
156192
password: <password>
157193

158194
[other]
159-
repository: http://example.com/pypi
195+
repository: https://example.com/pypi
160196
username: <username>
161197
password: <password>
162198

163-
:command:`register` can then be called with the -r option to point the
164-
repository to work with::
165-
166-
python setup.py register -r http://example.com/pypi
199+
This allows the :command:`register` and :command:`upload` commands to be
200+
called with the ``--repository`` option as described in
201+
:ref:`package-cmdoptions`.
167202

168-
For convenience, the name of the section that describes the repository
169-
may also be used::
170-
171-
python setup.py register -r other
203+
Specifically, you might want to add the `PyPI Test Repository
204+
<https://wiki.python.org/moin/TestPyPI>`_ to your ``.pypirc`` to facilitate
205+
testing before doing your first upload to ``PyPI`` itself.
172206

173207

174208
.. _package-display:
@@ -210,4 +244,4 @@ without warnings does not guarantee that PyPI will convert the content
210244
successfully.
211245

212246

213-
.. _Python Package Index (PyPI): http://pypi.python.org/
247+
.. _Python Package Index (PyPI): https://pypi.python.org/

0 commit comments

Comments
 (0)