Skip to content

Commit 54709a9

Browse files
committed
Cover package registration via twine
This change presents twine as a CLI option for registration as well. It also moves the note about manual .pypirc creation to the section on creating an account, as that is needed for `twine register` to work.
1 parent a4530c5 commit 54709a9

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

source/distributing.rst

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -732,25 +732,9 @@ account. There are two options:
732732
1. Create an account manually `using the form on the PyPI website
733733
<https://pypi.python.org/pypi?%3Aaction=register_form>`_.
734734

735-
2. Have an account created as part of registering your first project (see option
736-
#2 below).
737-
738-
739-
Register your project
740-
---------------------
741-
742-
Next, you need to register your project. There are two ways to do this:
743-
744-
1. **(Recommended):** Use `the form on the PyPI website
745-
<https://pypi.python.org/pypi?%3Aaction=submit_form>`_, to upload your
746-
``PKG-INFO`` info located in your local project tree at
747-
``myproject.egg-info/PKG-INFO``. If you don't have that file or directory,
748-
then run ``python setup.py egg_info`` to have it generated. Using the form is
749-
a secure option over using #2 below, which passes your credentials over
750-
plaintext.
751-
2. Run ``python setup.py register``. If you don't have a user account already,
752-
a wizard will create one for you.
753-
735+
2. **(Not recommended):** Have an account created as part of
736+
registering your first project (not recommended due to the
737+
related security concerns, see option #3 below).
754738

755739
If you created your account using option #1 (the form), you'll need to manually
756740
write a ``~/.pypirc`` file like so.
@@ -765,8 +749,29 @@ write a ``~/.pypirc`` file like so.
765749
username = <username>
766750
password = <password>
767751

768-
You can leave out the password line if below you use twine with its
769-
``-p PASSWORD`` argument.
752+
You can leave out the password line if you use twine with its
753+
``-p PASSWORD`` argument or prefer to simply enter your password
754+
when prompted.
755+
756+
757+
Register your project
758+
---------------------
759+
760+
Next, you need to register your project. There are three ways to do this:
761+
762+
1. Use `the form on the PyPI website
763+
<https://pypi.python.org/pypi?%3Aaction=submit_form>`_, to upload your
764+
``PKG-INFO`` info located in your local project tree at
765+
``myproject.egg-info/PKG-INFO``. If you don't have that file or directory,
766+
then run ``python setup.py egg_info`` to have it generated.
767+
2. Run ``twine register dist/*``, and :ref:`twine` will register your project
768+
based on the package metadata in the specified files. Your ``~/.pypirc``
769+
must already be appropriately configured for twine to work.
770+
3. **(Not recommended):** Run ``python setup.py register``. If you don't have
771+
a user account already, a wizard will create one for you. This approach is
772+
covered here due to it being mentioned in other guides, but it is not
773+
recommended as it uses a plaintext HTTP connection, allowing your username
774+
and password to be intercepted during transmission.
770775

771776

772777
Upload your distributions
@@ -777,7 +782,7 @@ Finally, you can upload your distributions to :term:`PyPI <Python Package Index
777782

778783
There are two options:
779784

780-
1. **(Recommended):** Use :ref:`twine`
785+
1. Use :ref:`twine`
781786

782787
::
783788

@@ -786,7 +791,7 @@ There are two options:
786791
The biggest reason to use twine is that ``python setup.py upload`` (option #2
787792
below) uploads files over plaintext. This means anytime you use it you expose
788793
your username and password to a MITM attack. Twine uses only verified TLS to
789-
upload to PyPI protecting your credentials from theft.
794+
upload to PyPI in order protect your credentials from theft.
790795

791796
Secondly it allows you to precreate your distribution files. ``python
792797
setup.py upload`` only allows you to upload something that you've created in
@@ -800,12 +805,15 @@ There are two options:
800805
the one directly executing ``gpg --detach-sign -a <filename>``.
801806

802807

803-
2. Use :ref:`setuptools`:
808+
2. **(Not recommended):** Use :ref:`setuptools`:
804809

805810
::
806811

807812
python setup.py sdist bdist_wheel upload
808813

814+
This approach is covered here due to it being mentioned in other guides, but it
815+
is not recommended as it uses a plaintext HTTP connection, allowing your username
816+
and password to be intercepted during transmission.
809817

810818
----
811819

0 commit comments

Comments
 (0)