@@ -5,6 +5,21 @@ This tutorial walks you through how to package a simple Python project. It will
55show you how to add the necessary files and structure to create the package, how
66to build the package, and how to upload it to the Python Package Index.
77
8+ Some of the commands require a newer version of :ref: `pip `, so start by making
9+ sure you have the latest version installed:
10+
11+ .. tab :: Unix/macOS
12+
13+ .. code-block :: bash
14+
15+ python3 -m pip install --upgrade pip
16+
17+ .. tab :: Windows
18+
19+ .. code-block :: bash
20+
21+ py -m pip install --upgrade pip
22+
823
924 A simple project
1025----------------
@@ -47,7 +62,6 @@ When you're done, the project structure will look like this:
4762 ├── pyproject.toml
4863 ├── README.md
4964 ├── setup.cfg
50- ├── setup.py # optional, needed to make editable pip installs work
5165 ├── src/
5266 │ └── example_pkg/
5367 │ └── __init__.py
@@ -105,8 +119,9 @@ There are two types of metadata: static and dynamic.
105119 dynamic or determined at install-time, as well as extension modules or
106120 extensions to setuptools, need to go into :file: `setup.py `.
107121
108- Static metadata should be preferred and dynamic metadata should be used only as
109- an escape hatch when absolutely necessary.
122+ Static metadata (:file: `setup.cfg `) should be preferred. Dynamic metadata (:file: `setup.py `)
123+ should be used only as an escape hatch when absolutely necessary. :file: `setup.py ` used to
124+ be required, but can be omitted with newer versions of setuptools and pip.
110125
111126
112127.. tab :: :file:`setup.cfg` (static)
@@ -203,27 +218,6 @@ an escape hatch when absolutely necessary.
203218 There are many more than the ones mentioned here. See
204219 :doc: `/guides/distributing-packages-using-setuptools ` for more details.
205220
206- If you create a :file: `setup.py ` file, this will enable direct interaction
207- with :file: `setup.py ` (which generally should be avoided), and editable
208- installs. This file used to be required, but can be omitted in modern
209- setuptools.
210-
211- .. warning ::
212-
213- If you include the file, you **must have ** a call to :func: `setup() ` in it,
214- even if there are no arguments:
215-
216- .. code-block :: python
217-
218- import setuptools
219-
220- setuptools.setup()
221-
222- Anything you set in :file: `setup.cfg ` can instead be set via keyword argument to
223- :func: `setup() `; this enables computed values to be used. You will also need
224- :func: `setup() ` for setting up extension modules for compilation. Currently,
225- having this file also is required if you want to use editable installs with pip.
226-
227221
228222.. tab :: :file:`setup.py` (dynamic)
229223
@@ -333,7 +327,7 @@ if you'd like.
333327 Because our configuration loads :file: `README.md ` to provide a
334328``long_description ``, :file: `README.md ` must be included along with your
335329code when you :ref: `generate a source distribution <generating archives >`.
336- Recent versions of :ref: `setuptools ` will do this automatically.
330+ Newer versions of :ref: `setuptools ` will do this automatically.
337331
338332
339333Creating a LICENSE
@@ -391,7 +385,7 @@ The next step is to generate :term:`distribution packages <Distribution
391385Package> ` for the package. These are archives that are uploaded to the Python
392386Package Index and can be installed by :ref: `pip `.
393387
394- Make sure you have the latest versions of PyPA's ``build `` installed:
388+ Make sure you have the latest version of PyPA's ``build `` installed:
395389
396390.. tab :: Unix/macOS
397391
@@ -474,13 +468,13 @@ distribution packages. You'll need to install Twine:
474468
475469 .. code-block :: bash
476470
477- python3 -m pip install --user -- upgrade twine
471+ python3 -m pip install --upgrade twine
478472
479473 .. tab :: Windows
480474
481475 .. code-block :: bash
482476
483- py -m pip install --user -- upgrade twine
477+ py -m pip install --upgrade twine
484478
485479 Once installed, run Twine to upload all of the archives under :file: `dist `:
486480
@@ -577,8 +571,9 @@ and from the interpreter shell import the package:
577571 >> > import example_pkg
578572
579573 Note that the :term: `import package <Import Package> ` is ``example_pkg ``
580- regardless of what name you gave your :term: `distribution package <Distribution
581- Package> ` in :file: `setup.py ` (in this case, ``example-pkg-YOUR-USERNAME-HERE ``).
574+ regardless of what ``name `` you gave your :term: `distribution package <Distribution
575+ Package> ` in :file: `setup.cfg ` or :file: `setup.py ` (in this case,
576+ ``example-pkg-YOUR-USERNAME-HERE ``).
582577
583578Next steps
584579----------
0 commit comments