Skip to content

Commit 66bde4c

Browse files
committed
Instruct users to upload to PyPI with tokens
API tokens are now a production feature of PyPI and users should use them instead of passwords to upload. Toward pypa#628. Signed-off-by: Sumana Harihareswara <[email protected]>
1 parent 45f9e5a commit 66bde4c

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

source/guides/distributing-packages-using-setuptools.rst

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -898,19 +898,29 @@ First, you need a :term:`PyPI <Python Package Index (PyPI)>` user account. You
898898
can create an account
899899
`using the form on the PyPI website <https://pypi.org/account/register/>`_.
900900

901-
.. Note:: If you want to avoid entering your username and password when
902-
uploading, you can create a ``$HOME/.pypirc`` file with your username and
903-
password:
901+
Now you'll create a PyPI `API token`_ so you will be able to securely upload
902+
your project.
903+
904+
Go to https://pypi.org/manage/account/#api-tokens and create a new
905+
`API token`_; don't limit its scope to a particular project, since you
906+
are creating a new project.
907+
908+
**Don't close the page until you have copied and saved the token — you
909+
won't see that token again.**
910+
911+
.. Note:: To avoid having to copy and paste the token every time you
912+
upload, you can create a ``$HOME/.pypirc`` file:
904913

905914
.. code-block:: text
906915
907916
[pypi]
908-
username = <username>
909-
password = <password>
917+
username = __token__
918+
password = <the token value, including the `pypi-` prefix>
910919
911-
**Be aware that this stores your password in plaintext.**
920+
**Be aware that this stores your token in plaintext.**
912921

913922
.. _register-your-project:
923+
.. _API token: https://pypi.org/help/#apitoken
914924

915925
Upload your distributions
916926
-------------------------

source/tutorials/packaging-projects.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,18 @@ You will also need to verify your email address before you're able to upload
231231
any packages. For more details on Test PyPI, see
232232
:doc:`/guides/using-testpypi`.
233233

234+
Now you'll create a PyPI `API token`_ so you will be able to securely upload
235+
your project.
236+
237+
Go to https://test.pypi.org/manage/account/#api-tokens and create a new
238+
`API token`_; don't limit its scope to a particular project, since you
239+
are creating a new project.
240+
241+
**Don't close the page until you have copied and saved the token — you
242+
won't see that token again.**
243+
244+
.. _API token: https://test.pypi.org/help/#apitoken
245+
234246
Now that you are registered, you can use :ref:`twine` to upload the
235247
distribution packages. You'll need to install Twine:
236248

@@ -244,8 +256,11 @@ Once installed, run Twine to upload all of the archives under :file:`dist`:
244256
245257
python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
246258
247-
You will be prompted for the username and password you registered with Test
248-
PyPI. After the command completes, you should see output similar to this:
259+
You will be prompted for a username and password. For the username,
260+
use ``__token__``. For the password, use the token value, including
261+
the ``pypi-`` prefix.
262+
263+
After the command completes, you should see output similar to this:
249264

250265
.. code-block:: bash
251266

0 commit comments

Comments
 (0)