blob: 297518bb8370b72c4684257c716198caca757583 [file] [log] [blame]
Éric Araujo3a9f58f2011-06-01 20:42:49 +02001.. _packaging-package-upload:
2
3***************************************
4Uploading Packages to the Package Index
5***************************************
6
7The Python Package Index (PyPI) not only stores the package info, but also the
8package data if the author of the package wishes to. The packaging command
9:command:`upload` pushes the distribution files to PyPI.
10
11The command is invoked immediately after building one or more distribution
12files. For example, the command ::
13
14 python setup.py sdist bdist_wininst upload
15
16will cause the source distribution and the Windows installer to be uploaded to
17PyPI. Note that these will be uploaded even if they are built using an earlier
18invocation of :file:`setup.py`, but that only distributions named on the command
19line for the invocation including the :command:`upload` command are uploaded.
20
21The :command:`upload` command uses the username, password, and repository URL
22from the :file:`$HOME/.pypirc` file (see section :ref:`packaging-pypirc` for more on this
23file). If a :command:`register` command was previously called in the same
24command, and if the password was entered in the prompt, :command:`upload` will
25reuse the entered password. This is useful if you do not want to store a clear
26text password in the :file:`$HOME/.pypirc` file.
27
28You can specify another PyPI server with the :option:`--repository=*url*`
29option::
30
31 python setup.py sdist bdist_wininst upload -r http://example.com/pypi
32
33See section :ref:`packaging-pypirc` for more on defining several servers.
34
35You can use the :option:`--sign` option to tell :command:`upload` to sign each
36uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must
37be available for execution on the system :envvar:`PATH`. You can also specify
38which key to use for signing using the :option:`--identity=*name*` option.
39
40Other :command:`upload` options include :option:`--repository=<url>` or
41:option:`--repository=<section>` where *url* is the url of the server and
42*section* the name of the section in :file:`$HOME/.pypirc`, and
43:option:`--show-response` (which displays the full response text from the PyPI
44server for help in debugging upload problems).
45
46PyPI package display
47====================
48
49The ``description`` field plays a special role at PyPI. It is used by
50the server to display a home page for the registered package.
51
52If you use the `reStructuredText <http://docutils.sourceforge.net/rst.html>`_
53syntax for this field, PyPI will parse it and display an HTML output for
54the package home page.
55
56The ``description`` field can be filled from a text file located in the
57project::
58
59 from packaging.core import setup
60
61 fp = open('README.txt')
62 try:
63 description = fp.read()
64 finally:
65 fp.close()
66
67 setup(name='Packaging',
68 description=description)
69
70In that case, :file:`README.txt` is a regular reStructuredText text file located
71in the root of the package besides :file:`setup.py`.
72
73To prevent registering broken reStructuredText content, you can use the
74:program:`rst2html` program that is provided by the :mod:`docutils` package
75and check the ``description`` from the command line::
76
77 $ python setup.py --description | rst2html.py > output.html
78
79:mod:`docutils` will display a warning if there's something wrong with your
80syntax.