Changeset 391 for python/trunk/Doc/distutils/packageindex.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
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 1 5 .. _package-index: 2 6 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 ******************************* 8 The Python Package Index (PyPI) 9 ******************************* 10 11 The `Python Package Index (PyPI)`_ holds :ref:`meta-data <meta-data>` 12 describing distributions packaged with distutils, as well as package data like 13 distribution files if the package author wishes. 14 15 Distutils exposes two commands for submitting package data to PyPI: the 16 :ref:`register <package-register>` command for submitting meta-data to PyPI 17 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. 22 23 24 .. _package-register: 25 26 Registering Packages 27 ==================== 28 29 The distutils command :command:`register` is used to submit your distribution's 30 meta-data to the index. It is invoked as follows:: 31 32 python setup.py register 12 33 13 34 Distutils will respond with the following prompt:: 14 35 15 running register16 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), or20 4. quit21 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]: 22 43 23 44 Note: if your username and password are saved locally, you will not see this … … 44 65 Maintainers. 45 66 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 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. 70 71 72 .. _package-upload: 73 74 Uploading Packages 75 ================== 76 77 .. versionadded:: 2.5 78 79 The distutils command :command:`upload` pushes the distribution files to PyPI. 80 81 The command is invoked immediately after building one or more distribution 82 files. For example, the command :: 83 84 python setup.py sdist bdist_wininst upload 85 86 will cause the source distribution and the Windows installer to be uploaded to 87 PyPI. Note that these will be uploaded even if they are built using an earlier 88 invocation of :file:`setup.py`, but that only distributions named on the command 89 line for the invocation including the :command:`upload` command are uploaded. 90 91 The :command:`upload` command uses the username, password, and repository URL 92 from the :file:`$HOME/.pypirc` file (see section :ref:`pypirc` for more on this 93 file). If a :command:`register` command was previously called in the same command, 94 and if the password was entered in the prompt, :command:`upload` will reuse the 95 entered password. This is useful if you do not want to store a clear text 96 password in the :file:`$HOME/.pypirc` file. 97 98 You 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 102 See section :ref:`pypirc` for more on defining several servers. 103 104 You can use the ``--sign`` option to tell :command:`upload` to sign each 105 uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must 106 be available for execution on the system :envvar:`PATH`. You can also specify 107 which key to use for signing using the ``--identity=name`` option. 108 109 Other :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 113 server for help in debugging upload problems). 114 115 116 .. index:: 117 single: .pypirc file 118 single: Python Package Index (PyPI); .pypirc file 50 119 51 120 .. _pypirc: … … 56 125 The format of the :file:`.pypirc` file is as follows:: 57 126 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 136 The *distutils* section defines a *index-servers* variable that lists the 137 name of all sections describing a repository. 138 139 Each 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 147 If you want to define another server a new section can be created and 148 listed 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 166 repository to work with:: 167 168 python setup.py register -r http://example.com/pypi 169 170 For convenience, the name of the section that describes the repository 171 may also be used:: 172 173 python setup.py register -r other 174 175 176 .. _package-display: 177 178 PyPI package display 179 ==================== 180 181 The ``long_description`` field plays a special role at PyPI. It is used by 182 the server to display a home page for the registered package. 183 184 If you use the `reStructuredText <http://docutils.sourceforge.net/rst.html>`_ 185 syntax for this field, PyPI will parse it and display an HTML output for 186 the package home page. 187 188 The ``long_description`` field can be attached to a text file located 189 in 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 199 In that case, :file:`README.txt` is a regular reStructuredText text file located 200 in the root of the package besides :file:`setup.py`. 201 202 To prevent registering broken reStructuredText content, you can use the 203 :program:`rst2html` program that is provided by the :mod:`docutils` package and 204 check 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 209 syntax. Because PyPI applies additional checks (e.g. by passing ``--no-raw`` 210 to ``rst2html.py`` in the command above), being able to run the command above 211 without warnings does not guarantee that PyPI will convert the content 212 successfully. 213 214 215 .. _Python Package Index (PyPI): http://pypi.python.org/
Note:
See TracChangeset
for help on using the changeset viewer.