1
1
.. image :: https://img.shields.io/pypi/v/twine.svg
2
- :target: https://pypi.org/project/twine
2
+ :target: https://pypi.org/project/twine
3
3
4
4
.. image :: https://img.shields.io/pypi/pyversions/twine.svg
5
- :target: https://pypi.org/project/twine
5
+ :target: https://pypi.org/project/twine
6
6
7
7
.. image :: https://img.shields.io/readthedocs/twine
8
- :target: https://twine.readthedocs.io
8
+ :target: https://twine.readthedocs.io
9
9
10
10
.. image :: https://img.shields.io/travis/com/pypa/twine
11
- :target: https://travis-ci.org/pypa/twine
11
+ :target: https://travis-ci.org/pypa/twine
12
12
13
13
.. image :: https://img.shields.io/codecov/c/github/pypa/twine
14
- :target: https://codecov.io/gh/pypa/twine
14
+ :target: https://codecov.io/gh/pypa/twine
15
15
16
16
twine
17
17
=====
18
18
19
- .. rtd-inclusion-marker-do-not-remove
20
-
21
- Twine is `a utility `_ for `publishing `_ Python packages on `PyPI `_.
19
+ Twine is a utility for `publishing `_ Python packages on `PyPI `_.
22
20
23
21
It provides build system independent uploads of source and binary
24
22
`distribution artifacts <distributions _>`_ for both new and existing
25
23
`projects `_.
26
24
27
-
28
- Why Should I Use This?
29
- ----------------------
30
-
31
- The goal of Twine is to improve PyPI interaction by improving
32
- security and testability.
33
-
34
- The biggest reason to use Twine is that it securely authenticates
35
- you to `PyPI `_ over HTTPS using a verified connection, regardless of
36
- the underlying Python version. Meanwhile, ``python setup.py upload ``
37
- will only work correctly and securely if your build system, Python
38
- version, and underlying operating system are configured properly.
39
-
40
- Secondly, Twine encourages you to build your distribution files. ``python
41
- setup.py upload `` only allows you to upload a package as a final step after
42
- building with ``distutils `` or ``setuptools ``, within the same command
43
- invocation. This means that you cannot test the exact file you're going to
44
- upload to PyPI to ensure that it works before uploading it.
45
-
46
- Finally, Twine allows you to pre-sign your files and pass the
47
- ``.asc `` files into the command line invocation (``twine upload
48
- myproject-1.0.1.tar.gz myproject-1.0.1.tar.gz.asc ``). This enables you
49
- to be assured that you're typing your ``gpg `` passphrase into ``gpg ``
50
- itself and not anything else, since *you * will be the one directly
51
- executing ``gpg --detach-sign -a <filename> ``.
52
-
53
-
54
- Features
55
- --------
56
-
57
- - Verified HTTPS connections
58
- - Uploading doesn't require executing ``setup.py ``
59
- - Uploading files that have already been created, allowing testing of
60
- distributions before release
61
- - Supports uploading any packaging format (including `wheels `_)
62
-
63
-
64
- Installation
65
- ------------
66
-
67
- .. code-block :: console
68
-
69
- $ pip install twine
70
-
71
-
72
- Using Twine
73
- -----------
74
-
75
- 1. Create some distributions in the normal way:
76
-
77
- .. code-block :: console
78
-
79
- $ python setup.py sdist bdist_wheel
80
-
81
- 2. Upload with ``twine `` to `Test PyPI `_ and verify things look right.
82
- Twine will automatically prompt for your username and password:
83
-
84
- .. code-block :: console
85
-
86
- $ twine upload -r testpypi dist/*
87
- username: ...
88
- password:
89
- ...
90
-
91
- 3. Upload to `PyPI `_:
92
-
93
- .. code-block :: console
94
-
95
- $ twine upload dist/*
96
-
97
- 4. Done!
98
-
99
- More documentation on using Twine to upload packages to PyPI is in
100
- the `Python Packaging User Guide `_.
101
-
102
- Keyring Support
103
- ---------------
104
-
105
- Instead of typing in your password every time you upload a distribution, Twine
106
- allows storing a username and password securely using `keyring `_.
107
- Keyring is installed with Twine but for some systems (Linux mainly) may
108
- require `additional installation steps `_.
109
-
110
- Once Twine is installed, use the ``keyring `` program to set a
111
- username and password to use for each package index (repository) to
112
- which you may upload.
113
-
114
- For example, to set a username and password for PyPI:
115
-
116
- .. code-block :: console
117
-
118
- $ keyring set https://upload.pypi.org/legacy/ your-username
119
-
120
- or
121
-
122
- .. code-block :: console
123
-
124
- $ python3 -m keyring set https://upload.pypi.org/legacy/ your-username
125
-
126
- and enter the password when prompted.
127
-
128
- For a different repository, replace the URL with the relevant repository
129
- URL. For example, for Test PyPI, use ``https://test.pypi.org/legacy/ ``.
130
-
131
- The next time you run ``twine ``, it will prompt you for a username and will grab
132
- the appropriate password from the keyring.
133
-
134
- **Note: ** If you are using Linux in a headless environment (such as on a server)
135
- you'll need to do some additional steps to ensure that Keyring can store secrets
136
- securely. See `Using Keyring on headless systems `_.
137
-
138
-
139
- Disabling Keyring
140
- ^^^^^^^^^^^^^^^^^
141
-
142
- In most cases, simply not setting a password with ``keyring `` will allow Twine
143
- to fall back to prompting for a password. In some cases, the presence of
144
- Keyring will cause unexpected or undesirable prompts from the backing
145
- system. In these cases, it may be desirable to disable Keyring altogether.
146
- To disable Keyring, simply invoke:
147
-
148
- .. code-block :: console
149
-
150
- $ keyring --disable
151
-
152
- or
153
-
154
- .. code-block :: console
155
-
156
- $ python -m keyring --disable
157
-
158
- That command will configure for the current user the "null" keyring,
159
- effectively disabling the functionality, and allowing Twine to prompt
160
- for passwords.
161
-
162
- See `twine 338 <https://github.com/pypa/twine/issues/338 >`_ for
163
- discussion and background.
164
-
165
- Options
166
- -------
167
-
168
- ``twine upload ``
169
- ^^^^^^^^^^^^^^^^
170
-
171
- Uploads one or more distributions to a repository.
172
-
173
- .. code-block :: console
174
-
175
- $ twine upload -h
176
- usage: twine upload [-h] [-r REPOSITORY] [--repository-url REPOSITORY_URL]
177
- [-s] [--sign-with SIGN_WITH] [-i IDENTITY] [-u USERNAME]
178
- [-p PASSWORD] [-c COMMENT] [--config-file CONFIG_FILE]
179
- [--skip-existing] [--cert path] [--client-cert path]
180
- [--verbose] [--disable-progress-bar]
181
- dist [dist ...]
182
-
183
- positional arguments:
184
- dist The distribution files to upload to the repository
185
- (package index). Usually dist/* . May additionally
186
- contain a .asc file to include an existing signature
187
- with the file upload.
188
-
189
- optional arguments:
190
- -h, --help show this help message and exit
191
- -r REPOSITORY, --repository REPOSITORY
192
- The repository (package index) to upload the package
193
- to. Should be a section in the config file (default:
194
- pypi). (Can also be set via TWINE_REPOSITORY
195
- environment variable.)
196
- --repository-url REPOSITORY_URL
197
- The repository (package index) URL to upload the
198
- package to. This overrides --repository. (Can also be
199
- set via TWINE_REPOSITORY_URL environment variable.)
200
- -s, --sign Sign files to upload using GPG.
201
- --sign-with SIGN_WITH
202
- GPG program used to sign uploads (default: gpg).
203
- -i IDENTITY, --identity IDENTITY
204
- GPG identity used to sign files.
205
- -u USERNAME, --username USERNAME
206
- The username to authenticate to the repository
207
- (package index) as. (Can also be set via
208
- TWINE_USERNAME environment variable.)
209
- -p PASSWORD, --password PASSWORD
210
- The password to authenticate to the repository
211
- (package index) with. (Can also be set via
212
- TWINE_PASSWORD environment variable.)
213
- --non-interactive Do not interactively prompt for username/password
214
- if the required credentials are missing. (Can also
215
- be set via TWINE_NON_INTERACTIVE environment
216
- variable.)
217
- -c COMMENT, --comment COMMENT
218
- The comment to include with the distribution file.
219
- --config-file CONFIG_FILE
220
- The .pypirc config file to use.
221
- --skip-existing Continue uploading files if one already exists. (Only
222
- valid when uploading to PyPI. Other implementations
223
- may not support this.)
224
- --cert path Path to alternate CA bundle (can also be set via
225
- TWINE_CERT environment variable).
226
- --client-cert path Path to SSL client certificate, a single file
227
- containing the private key and the certificate in PEM
228
- format.
229
- --verbose Show verbose output.
230
- --disable-progress-bar
231
- Disable the progress bar.
232
-
233
- ``twine check ``
234
- ^^^^^^^^^^^^^^^
235
-
236
- Checks whether your distribution's long description will render correctly on
237
- PyPI.
238
-
239
- .. code-block :: console
240
-
241
- $ twine check -h
242
- usage: twine check [-h] dist [dist ...]
243
-
244
- positional arguments:
245
- dist The distribution files to check, usually dist/*
246
-
247
- optional arguments:
248
- -h, --help show this help message and exit
249
-
250
- ``twine register ``
251
- ^^^^^^^^^^^^^^^^^^
252
-
253
- **WARNING **: The ``register `` command is `no longer necessary if you are
254
- uploading to pypi.org `_. As such, it is `no longer supported `_ in `Warehouse `_
255
- (the new PyPI software running on pypi.org). However, you may need this if you
256
- are using a different package index.
257
-
258
- For completeness, its usage:
259
-
260
- .. code-block :: console
261
-
262
- $ twine register -h
263
-
264
- usage: twine register [-h] -r REPOSITORY [--repository-url REPOSITORY_URL]
265
- [-u USERNAME] [-p PASSWORD] [-c COMMENT]
266
- [--config-file CONFIG_FILE] [--cert path]
267
- [--client-cert path]
268
- package
269
-
270
- positional arguments:
271
- package File from which we read the package metadata.
272
-
273
- optional arguments:
274
- -h, --help show this help message and exit
275
- -r REPOSITORY, --repository REPOSITORY
276
- The repository (package index) to register the package
277
- to. Should be a section in the config file. (Can also
278
- be set via TWINE_REPOSITORY environment variable.)
279
- Initial package registration no longer necessary on
280
- pypi.org:
281
- https://packaging.python.org/guides/migrating-to-pypi-
282
- org/
283
- --repository-url REPOSITORY_URL
284
- The repository (package index) URL to register the
285
- package to. This overrides --repository. (Can also be
286
- set via TWINE_REPOSITORY_URL environment variable.)
287
- -u USERNAME, --username USERNAME
288
- The username to authenticate to the repository
289
- (package index) as. (Can also be set via
290
- TWINE_USERNAME environment variable.)
291
- -p PASSWORD, --password PASSWORD
292
- The password to authenticate to the repository
293
- (package index) with. (Can also be set via
294
- TWINE_PASSWORD environment variable.)
295
- --non-interactive Do not interactively prompt for username/password
296
- if the required credentials are missing. (Can also
297
- be set via TWINE_NON_INTERACTIVE environment
298
- variable.)
299
- -c COMMENT, --comment COMMENT
300
- The comment to include with the distribution file.
301
- --config-file CONFIG_FILE
302
- The .pypirc config file to use.
303
- --cert path Path to alternate CA bundle (can also be set via
304
- TWINE_CERT environment variable).
305
- --client-cert path Path to SSL client certificate, a single file
306
- containing the private key and the certificate in PEM
307
- format.
308
-
309
- Configuration File
310
- ^^^^^^^^^^^^^^^^^^
311
-
312
- Twine can read repository configuration from a ``.pypirc `` file, either in your
313
- home directory, or provided with the ``--config-file `` option. For details on
314
- writing and using ``.pypirc ``, see the `specification <pypirc _>`_ in the Python
315
- Packaging User Guide.
316
-
317
- Environment Variables
318
- ^^^^^^^^^^^^^^^^^^^^^
319
-
320
- Twine also supports configuration via environment variables. Options passed on
321
- the command line will take precedence over options set via environment
322
- variables. Definition via environment variable is helpful in environments where
323
- it is not convenient to create a ``.pypirc `` file (for example,
324
- on a CI/build server).
325
-
326
- * ``TWINE_USERNAME `` - the username to use for authentication to the repository.
327
- * ``TWINE_PASSWORD `` - the password to use for authentication to the repository.
328
- * ``TWINE_REPOSITORY `` - the repository configuration, either defined as a
329
- section in ``.pypirc `` or provided as a full URL.
330
- * ``TWINE_REPOSITORY_URL `` - the repository URL to use.
331
- * ``TWINE_CERT `` - custom CA certificate to use for repositories with
332
- self-signed or untrusted certificates.
333
- * ``TWINE_NON_INTERACTIVE `` - Do not interactively prompt for username/password
334
- if the required credentials are missing.
335
-
336
- Resources
337
- ---------
338
-
339
- * `IRC <https://webchat.freenode.net/?channels=%23pypa >`_
340
- (``#pypa `` - irc.freenode.net)
341
- * `GitHub repository <https://github.com/pypa/twine >`_
342
- * User and developer `documentation `_
343
- * `Python Packaging User Guide `_
25
+ See our `documentation `_ for a description of features, installation
26
+ and usage instructions, and links to additional resources.
344
27
345
28
Contributing
346
29
------------
@@ -355,27 +38,12 @@ Everyone interacting in the Twine project's codebases, issue
355
38
trackers, chat rooms, and mailing lists is expected to follow the
356
39
`PyPA Code of Conduct `_.
357
40
358
- .. _`a utility` : https://pypi.org/project/twine/
359
41
.. _`publishing` : https://packaging.python.org/tutorials/distributing-packages/
360
42
.. _`PyPI` : https://pypi.org
361
- .. _`Test PyPI` : https://packaging.python.org/guides/using-testpypi/
362
- .. _`pypirc` : https://packaging.python.org/specifications/pypirc/
363
- .. _`Python Packaging User Guide` :
364
- https://packaging.python.org/tutorials/distributing-packages/
365
- .. _`keyring` : https://pypi.org/project/keyring/
366
- .. _`Using Keyring on headless systems` :
367
- https://keyring.readthedocs.io/en/latest/#using-keyring-on-headless-linux-systems
368
- .. _`additional installation steps` :
369
- https://pypi.org/project/keyring/#installation-linux
43
+ .. _`distributions` :
44
+ https://packaging.python.org/glossary/#term-distribution-package
45
+ .. _`projects` : https://packaging.python.org/glossary/#term-project
370
46
.. _`documentation` : https://twine.readthedocs.io/
371
47
.. _`developer documentation` :
372
- https://twine.readthedocs.io/en/latest/contributing.html
373
- .. _`projects` : https://packaging.python.org/glossary/#term-project
374
- .. _`distributions` :
375
- https://packaging.python.org/glossary/#term-distribution-package
48
+ https://twine.readthedocs.io/en/latest/contributing.html
376
49
.. _`PyPA Code of Conduct` : https://www.pypa.io/en/latest/code-of-conduct/
377
- .. _`Warehouse` : https://github.com/pypa/warehouse
378
- .. _`wheels` : https://packaging.python.org/glossary/#term-wheel
379
- .. _`no longer necessary if you are uploading to pypi.org` :
380
- https://packaging.python.org/guides/migrating-to-pypi-org/#registering-package-names-metadata
381
- .. _`no longer supported` : https://github.com/pypa/warehouse/issues/1627
0 commit comments