blob: 84388c2124ab5fe2cc9d36488c87c9ea0e8552f3 [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001.. _package-upload:
2
3***************************************
4Uploading Packages to the Package Index
5***************************************
6
7.. versionadded:: 2.5
8
9The Python Package Index (PyPI) not only stores the package info, but also the
10package data if the author of the package wishes to. The distutils command
11:command:`upload` pushes the distribution files to PyPI.
12
13The command is invoked immediately after building one or more distribution
14files. For example, the command ::
15
Tarek Ziadé1a240fb2009-01-08 23:56:31 +000016 python setup.py sdist bdist_wininst upload
Georg Brandl8ec7f652007-08-15 14:28:01 +000017
18will cause the source distribution and the Windows installer to be uploaded to
19PyPI. Note that these will be uploaded even if they are built using an earlier
20invocation of :file:`setup.py`, but that only distributions named on the command
21line for the invocation including the :command:`upload` command are uploaded.
22
23The :command:`upload` command uses the username, password, and repository URL
24from the :file:`$HOME/.pypirc` file (see section :ref:`pypirc` for more on this
Tarek Ziadé1a240fb2009-01-08 23:56:31 +000025file). If a :command:`register` command was previously called in the same command,
26and if the password was entered in the prompt, :command:`upload` will reuse the
27entered password. This is useful if you do not want to store a clear text
28password in the :file:`$HOME/.pypirc` file.
Georg Brandl8ec7f652007-08-15 14:28:01 +000029
Andrew M. Kuchlingaac5c862008-05-11 14:00:00 +000030You can specify another PyPI server with the :option:`--repository=*url*` option::
31
Tarek Ziadé1a240fb2009-01-08 23:56:31 +000032 python setup.py sdist bdist_wininst upload -r http://example.com/pypi
Andrew M. Kuchlingaac5c862008-05-11 14:00:00 +000033
34See section :ref:`pypirc` for more on defining several servers.
35
Georg Brandl8ec7f652007-08-15 14:28:01 +000036You can use the :option:`--sign` option to tell :command:`upload` to sign each
37uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must
38be available for execution on the system :envvar:`PATH`. You can also specify
39which key to use for signing using the :option:`--identity=*name*` option.
40
Georg Brandle92818f2009-01-03 20:47:01 +000041Other :command:`upload` options include :option:`--repository=<url>` or
42:option:`--repository=<section>` where *url* is the url of the server and
43*section* the name of the section in :file:`$HOME/.pypirc`, and
Georg Brandl8ec7f652007-08-15 14:28:01 +000044:option:`--show-response` (which displays the full response text from the PyPI
45server for help in debugging upload problems).
Tarek Ziadé75a4fab2009-02-27 02:14:35 +000046
47PyPI package display
48====================
49
50The ``long_description`` field plays a special role at PyPI. It is used by
51the server to display a home page for the registered package.
52
53If you use the `reStructuredText <http://docutils.sourceforge.net/rst.html>`_
54syntax for this field, PyPI will parse it and display an HTML output for
55the package home page.
56
57The ``long_description`` field can be attached to a text file located
58in the package::
59
60 from distutils.core import setup
61
62 setup(name='Distutils',
63 long_description=open('README.txt'))
64
65In that case, `README.txt` is a regular reStructuredText text file located
66in the root of the package besides `setup.py`.
67
68To prevent registering broken reStructuredText content, you can use the
69:program:`rst2html` program that is provided by the `docutils` package
70and check the ``long_description`` from the command line::
71
72 $ python setup.py --long-description | rst2html.py > output.html
73
74`docutils` will display a warning if there's something wrong with your syntax.