Skip to content

Add instructions on how to use keyring #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 61 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,23 @@ Installation
$ pip install twine


Usage
-----
Using Twine
-----------

1. Create some distributions in the normal way:

.. code-block:: console

$ python setup.py sdist bdist_wheel

2. Upload with ``twine`` to `Test PyPI`_ and verify things look right:
2. Upload with ``twine`` to `Test PyPI`_ and verify things look right. Twine will automatically prompt for your username and password:

.. code-block:: console

$ twine upload --repository-url https://test.pypi.org/legacy/ dist/*
username: ...
password:
...

3. Upload to `PyPI`_:

Expand All @@ -81,9 +84,58 @@ Usage
More documentation on using ``twine`` to upload packages to PyPI is in
the `Python Packaging User Guide`_.

Keyring Support
---------------

Instead of typing in your password every time you upload a distribution, Twine
allows you to store your username and password securely using `keyring`_.

To use the keyring, you must first install the keyring packages:

- On Windows and MacOS you just need to install ``keyring``, for example,
``pip install --user keyring``.
- On Linux, in addition to the ``keyring`` package you also need to ensure the
``python3-dbus`` system package is installed. For example, ``apt install
python3-dbus``. See `Keyring's installation instructions`_ for more details.

Once keyring is installed you can use the ``keyring`` program to set your
username and password to use for each package index (repository) you want to
upload to using Twine.

To set your username and password for test PyPI run the following command.
``keyring`` will prompt you for your password:

.. code-block:: console

$ keyring set https://test.pypi.org/legacy/ your-username
# or
$ python3 -m keyring set https://test.pypi.org/legacy/ your-username
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you find some way here to indicate that it'll ask you to input a password? And I have the same suggestion for line 116-117.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


To set your username and password for PyPI run this command, again, ``keyring``
will prompt for the password:

.. code-block:: console

$ keyring set https://upload.pypi.org/legacy/ your-username
# or
$ python3 -m keyring set https://upload.pypi.org/legacy/ your-username


The next time you run ``twine`` it will prompt you for a username and will grab the appropriate password from the keyring.

.. Note:: If you are using Linux in a headless environment (such as on a
server) you'll need to do some additional steps to ensure that Keyring can
store secrets securely. See `Using Keyring on headless systems`_.

.. _`keyring`: https://pypi.org/project/keyring/
.. _`Keyring's installation instructions`:
https://keyring.readthedocs.io/en/latest#installation-instructions
.. _`Using Keyring on headless systems`:
https://keyring.readthedocs.io/en/latest/#using-keyring-on-headless-linux-systems


Options
^^^^^^^
-------

.. code-block:: console

Expand Down Expand Up @@ -205,13 +257,13 @@ variables. Definition via environment variable is helpful in environments where
it is not convenient to create a `.pypirc` file, such as a CI/build server, for
example.

* ``TWINE_USERNAME`` - the username to use for authentication to the repository
* ``TWINE_PASSWORD`` - the password to use for authentication to the repository
* ``TWINE_USERNAME`` - the username to use for authentication to the repository.
* ``TWINE_PASSWORD`` - the password to use for authentication to the repository.
* ``TWINE_REPOSITORY`` - the repository configuration, either defined as a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For parallelism, could you add the ending period to all the items in this list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

section in `.pypirc` or provided as a full URL
* ``TWINE_REPOSITORY_URL`` - the repository URL to use
section in `.pypirc` or provided as a full URL.
* ``TWINE_REPOSITORY_URL`` - the repository URL to use.
* ``TWINE_CERT`` - custom CA certificate to use for repositories with
self-signed or untrusted certificates
self-signed or untrusted certificates.

Resources
---------
Expand Down