Skip to content

Commit

Permalink
Merge pull request #687 from brainwane/tokens-for-upload
Browse files Browse the repository at this point in the history
Instruct users to upload to PyPI with tokens
  • Loading branch information
di committed Jan 16, 2020
2 parents 45f9e5a + 66bde4c commit 4fe7e33
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
22 changes: 16 additions & 6 deletions source/guides/distributing-packages-using-setuptools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -898,19 +898,29 @@ First, you need a :term:`PyPI <Python Package Index (PyPI)>` user account. You
can create an account
`using the form on the PyPI website <https://pypi.org/account/register/>`_.

.. Note:: If you want to avoid entering your username and password when
uploading, you can create a ``$HOME/.pypirc`` file with your username and
password:
Now you'll create a PyPI `API token`_ so you will be able to securely upload
your project.

Go to https://pypi.org/manage/account/#api-tokens and create a new
`API token`_; don't limit its scope to a particular project, since you
are creating a new project.

**Don't close the page until you have copied and saved the token — you
won't see that token again.**

.. Note:: To avoid having to copy and paste the token every time you
upload, you can create a ``$HOME/.pypirc`` file:

.. code-block:: text
[pypi]
username = <username>
password = <password>
username = __token__
password = <the token value, including the `pypi-` prefix>
**Be aware that this stores your password in plaintext.**
**Be aware that this stores your token in plaintext.**

.. _register-your-project:
.. _API token: https://pypi.org/help/#apitoken

Upload your distributions
-------------------------
Expand Down
19 changes: 17 additions & 2 deletions source/tutorials/packaging-projects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ You will also need to verify your email address before you're able to upload
any packages. For more details on Test PyPI, see
:doc:`/guides/using-testpypi`.

Now you'll create a PyPI `API token`_ so you will be able to securely upload
your project.

Go to https://test.pypi.org/manage/account/#api-tokens and create a new
`API token`_; don't limit its scope to a particular project, since you
are creating a new project.

**Don't close the page until you have copied and saved the token — you
won't see that token again.**

.. _API token: https://test.pypi.org/help/#apitoken

Now that you are registered, you can use :ref:`twine` to upload the
distribution packages. You'll need to install Twine:

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

After the command completes, you should see output similar to this:

.. code-block:: bash
Expand Down

0 comments on commit 4fe7e33

Please sign in to comment.