blob: 1b3cb589ecc6b5a5c884ef2f37a8adc92ff8cba0 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001.. _package-upload:
2
3***************************************
4Uploading Packages to the Package Index
5***************************************
6
Georg Brandl116aa622007-08-15 14:28:22 +00007The Python Package Index (PyPI) not only stores the package info, but also the
8package data if the author of the package wishes to. The distutils 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
Tarek Ziadé13f7c3b2009-01-09 00:15:45 +000014 python setup.py sdist bdist_wininst upload
Georg Brandl116aa622007-08-15 14:28:22 +000015
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:`pypirc` for more on this
Tarek Ziadé13f7c3b2009-01-09 00:15:45 +000023file). If a :command:`register` command was previously called in the same command,
24and if the password was entered in the prompt, :command:`upload` will reuse the
25entered password. This is useful if you do not want to store a clear text
26password in the :file:`$HOME/.pypirc` file.
Georg Brandl116aa622007-08-15 14:28:22 +000027
Alexandre Vassalotti5f8ced22008-05-16 00:03:33 +000028You can specify another PyPI server with the :option:`--repository=*url*` option::
29
Tarek Ziadé13f7c3b2009-01-09 00:15:45 +000030 python setup.py sdist bdist_wininst upload -r http://example.com/pypi
Alexandre Vassalotti5f8ced22008-05-16 00:03:33 +000031
32See section :ref:`pypirc` for more on defining several servers.
33
Georg Brandl116aa622007-08-15 14:28:22 +000034You can use the :option:`--sign` option to tell :command:`upload` to sign each
35uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must
36be available for execution on the system :envvar:`PATH`. You can also specify
37which key to use for signing using the :option:`--identity=*name*` option.
38
Georg Brandl36ab1ef2009-01-03 21:17:04 +000039Other :command:`upload` options include :option:`--repository=<url>` or
40:option:`--repository=<section>` where *url* is the url of the server and
41*section* the name of the section in :file:`$HOME/.pypirc`, and
Georg Brandl116aa622007-08-15 14:28:22 +000042:option:`--show-response` (which displays the full response text from the PyPI
43server for help in debugging upload problems).
Tarek Ziadé3177f2f2009-02-27 02:22:25 +000044
45PyPI package display
46====================
47
48The ``long_description`` field plays a special role at PyPI. It is used by
49the server to display a home page for the registered package.
50
51If you use the `reStructuredText <http://docutils.sourceforge.net/rst.html>`_
52syntax for this field, PyPI will parse it and display an HTML output for
53the package home page.
54
55The ``long_description`` field can be attached to a text file located
56in the package::
57
58 from distutils.core import setup
59
Éric Araujo7d9d34f2011-02-25 21:45:06 +000060 with open('README.txt') as file:
61 long_description = file.read()
62
Tarek Ziadé3177f2f2009-02-27 02:22:25 +000063 setup(name='Distutils',
Éric Araujo7d9d34f2011-02-25 21:45:06 +000064 long_description=long_description)
Tarek Ziadé3177f2f2009-02-27 02:22:25 +000065
Senthil Kumaran82270452010-10-15 13:29:33 +000066In that case, :file:`README.txt` is a regular reStructuredText text file located
67in the root of the package besides :file:`setup.py`.
Tarek Ziadé3177f2f2009-02-27 02:22:25 +000068
69To prevent registering broken reStructuredText content, you can use the
Senthil Kumaran82270452010-10-15 13:29:33 +000070:program:`rst2html` program that is provided by the :mod:`docutils` package and
71check the ``long_description`` from the command line::
Tarek Ziadé3177f2f2009-02-27 02:22:25 +000072
73 $ python setup.py --long-description | rst2html.py > output.html
74
Senthil Kumaran82270452010-10-15 13:29:33 +000075:mod:`docutils` will display a warning if there's something wrong with your
76syntax.