Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/distutils/packageindex.rst

    r2 r391  
     1.. index::
     2   single: Python Package Index (PyPI)
     3   single: PyPI; (see Python Package Index (PyPI))
     4
    15.. _package-index:
    26
    3 **********************************
    4 Registering with the Package Index
    5 **********************************
    6 
    7 The Python Package Index (PyPI) holds meta-data describing distributions
    8 packaged with distutils. The distutils command :command:`register` is used to
    9 submit your distribution's meta-data to the index. It is invoked as follows::
    10 
    11    python setup.py register
     7*******************************
     8The Python Package Index (PyPI)
     9*******************************
     10
     11The `Python Package Index (PyPI)`_ holds :ref:`meta-data <meta-data>`
     12describing distributions packaged with distutils, as well as package data like
     13distribution files if the package author wishes.
     14
     15Distutils exposes two commands for submitting package data to PyPI: the
     16:ref:`register <package-register>` command for submitting meta-data to PyPI
     17and the :ref:`upload <package-upload>` command for submitting distribution
     18files.  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``
     21submitted by the :command:`register` command.
     22
     23
     24.. _package-register:
     25
     26Registering Packages
     27====================
     28
     29The distutils command :command:`register` is used to submit your distribution's
     30meta-data to the index. It is invoked as follows::
     31
     32    python setup.py register
    1233
    1334Distutils will respond with the following prompt::
    1435
    15    running register
    16    We need to know who you are, so please choose either:
    17     1. use your existing login,
    18     2. register as a new user,
    19     3. have the server generate a new password for you (and email it to you), or
    20     4. quit
    21    Your selection [default 1]:
     36    running register
     37    We need to know who you are, so please choose either:
     38        1. use your existing login,
     39        2. register as a new user,
     40        3. have the server generate a new password for you (and email it to you), or
     41        4. quit
     42    Your selection [default 1]:
    2243
    2344Note: if your username and password are saved locally, you will not see this
     
    4465Maintainers.
    4566
    46 By default PyPI will list all versions of a given package. To hide certain
    47 versions, the Hidden property should be set to yes. This must be edited through
    48 the web interface.
    49 
     67By default PyPI displays only the newest version of a given package. The web
     68interface lets one change this default behavior and manually select which
     69versions to display and hide.
     70
     71
     72.. _package-upload:
     73
     74Uploading Packages
     75==================
     76
     77.. versionadded:: 2.5
     78
     79The distutils command :command:`upload` pushes the distribution files to PyPI.
     80
     81The command is invoked immediately after building one or more distribution
     82files.  For example, the command ::
     83
     84    python setup.py sdist bdist_wininst upload
     85
     86will cause the source distribution and the Windows installer to be uploaded to
     87PyPI.  Note that these will be uploaded even if they are built using an earlier
     88invocation of :file:`setup.py`, but that only distributions named on the command
     89line for the invocation including the :command:`upload` command are uploaded.
     90
     91The :command:`upload` command uses the username, password, and repository URL
     92from the :file:`$HOME/.pypirc` file (see section :ref:`pypirc` for more on this
     93file). If a :command:`register` command was previously called in the same command,
     94and if the password was entered in the prompt, :command:`upload` will reuse the
     95entered password. This is useful if you do not want to store a clear text
     96password in the :file:`$HOME/.pypirc` file.
     97
     98You can specify another PyPI server with the ``--repository=url`` option::
     99
     100    python setup.py sdist bdist_wininst upload -r http://example.com/pypi
     101
     102See section :ref:`pypirc` for more on defining several servers.
     103
     104You can use the ``--sign`` option to tell :command:`upload` to sign each
     105uploaded file using GPG (GNU Privacy Guard).  The  :program:`gpg` program must
     106be available for execution on the system :envvar:`PATH`.  You can also specify
     107which key to use for signing using the ``--identity=name`` option.
     108
     109Other :command:`upload` options include ``--repository=url`` or
     110``--repository=section`` where *url* is the url of the server and
     111*section* the name of the section in :file:`$HOME/.pypirc`, and
     112``--show-response`` (which displays the full response text from the PyPI
     113server for help in debugging upload problems).
     114
     115
     116.. index::
     117   single: .pypirc file
     118   single: Python Package Index (PyPI); .pypirc file
    50119
    51120.. _pypirc:
     
    56125The format of the :file:`.pypirc` file is as follows::
    57126
    58    [distutils]
    59    index-servers =
    60      pypi
    61 
    62    [pypi]
    63    repository: <repository-url>
    64    username: <username>
    65    password: <password>
    66 
    67 *repository* can be omitted and defaults to ``http://www.python.org/pypi``.
    68 
    69 If you want to define another server a new section can be created::
    70 
    71    [distutils]
    72    index-servers =
    73      pypi
    74      other
    75 
    76    [pypi]
    77    repository: <repository-url>
    78    username: <username>
    79    password: <password>
    80 
    81    [other]
    82    repository: http://example.com/pypi
    83    username: <username>
    84    password: <password>
    85 
    86 The command can then be called with the -r option::
    87 
    88    python setup.py register -r http://example.com/pypi
    89 
    90 Or even with the section name::
    91 
    92    python setup.py register -r other
    93 
     127    [distutils]
     128    index-servers =
     129        pypi
     130
     131    [pypi]
     132    repository: <repository-url>
     133    username: <username>
     134    password: <password>
     135
     136The *distutils* section defines a *index-servers* variable that lists the
     137name of all sections describing a repository.
     138
     139Each section describing a repository defines three variables:
     140
     141- *repository*, that defines the url of the PyPI server. Defaults to
     142    ``http://www.python.org/pypi``.
     143- *username*, which is the registered username on the PyPI server.
     144- *password*, that will be used to authenticate. If omitted the user
     145    will be prompt to type it when needed.
     146
     147If you want to define another server a new section can be created and
     148listed in the *index-servers* variable::
     149
     150    [distutils]
     151    index-servers =
     152        pypi
     153        other
     154
     155    [pypi]
     156    repository: <repository-url>
     157    username: <username>
     158    password: <password>
     159
     160    [other]
     161    repository: http://example.com/pypi
     162    username: <username>
     163    password: <password>
     164
     165:command:`register` can then be called with the -r option to point the
     166repository to work with::
     167
     168    python setup.py register -r http://example.com/pypi
     169
     170For convenience, the name of the section that describes the repository
     171may also be used::
     172
     173    python setup.py register -r other
     174
     175
     176.. _package-display:
     177
     178PyPI package display
     179====================
     180
     181The ``long_description`` field plays a special role at PyPI. It is used by
     182the server to display a home page for the registered package.
     183
     184If you use the `reStructuredText <http://docutils.sourceforge.net/rst.html>`_
     185syntax for this field, PyPI will parse it and display an HTML output for
     186the package home page.
     187
     188The ``long_description`` field can be attached to a text file located
     189in the package::
     190
     191    from distutils.core import setup
     192
     193    with open('README.txt') as file:
     194        long_description = file.read()
     195
     196    setup(name='Distutils',
     197          long_description=long_description)
     198
     199In that case, :file:`README.txt` is a regular reStructuredText text file located
     200in the root of the package besides :file:`setup.py`.
     201
     202To prevent registering broken reStructuredText content, you can use the
     203:program:`rst2html` program that is provided by the :mod:`docutils` package and
     204check the ``long_description`` from the command line::
     205
     206    $ python setup.py --long-description | rst2html.py > output.html
     207
     208:mod:`docutils` will display a warning if there's something wrong with your
     209syntax.  Because PyPI applies additional checks (e.g. by passing ``--no-raw``
     210to ``rst2html.py`` in the command above), being able to run the command above
     211without warnings does not guarantee that PyPI will convert the content
     212successfully.
     213
     214
     215.. _Python Package Index (PyPI): http://pypi.python.org/
Note: See TracChangeset for help on using the changeset viewer.