You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/tutorials/packaging-projects.rst
+20-29Lines changed: 20 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ A simple project
11
11
12
12
This tutorial uses a simple project named ``example_pkg``. If you are unfamiliar
13
13
with Python's modules and :term:`import packages <import package>`, take a few
14
-
minutes to read over the `Python documentation for packages and modules`_.
14
+
minutes to read over the `Python documentation for packages and modules`_. Even if you already have a project that you want to package up, we recommend following this tutorial as-is using this example package and then trying with your own package.
15
15
16
16
To create this project locally, create the following file structure:
17
17
@@ -29,7 +29,7 @@ You should also edit :file:`example_pkg/__init__.py` and put the following
29
29
code in there:
30
30
31
31
.. code-block:: python
32
-
32
+
33
33
name ="example_pkg"
34
34
35
35
This is just so that you can verify that it installed correctly later in this
@@ -63,8 +63,7 @@ Creating setup.py
63
63
about your package (such as the name and version) as well as which code files
64
64
to include.
65
65
66
-
Open :file:`setup.py` and enter the following content, you can personalize
67
-
the values if you want:
66
+
Open :file:`setup.py` and enter the following content. You **should** update the package name to include your username (for example, ``example-pkg-theacodes``. You can personalize the other values if you'd like:
68
67
69
68
.. code-block:: python
70
69
@@ -74,7 +73,7 @@ the values if you want:
74
73
long_description = fh.read()
75
74
76
75
setuptools.setup(
77
-
name="example_pkg",
76
+
name="example-pkg-your-username",
78
77
version="0.0.1",
79
78
author="Example Author",
80
79
author_email="author@example.com",
@@ -94,9 +93,9 @@ the values if you want:
94
93
:func:`setup` takes several arguments. This example package uses a relatively
95
94
minimal set:
96
95
97
-
- ``name`` is the name of your package. This can be any name as long as only
96
+
- ``name`` is the *distribution name* of your package. This can be any name as long as only
98
97
contains letters, numbers, ``_`` , and ``-``. It also must not already
99
-
taken on pypi.org.
98
+
taken on pypi.org. **Be sure to update this with your username,** as this ensures you won't run into any name collisions when you upload the package.
100
99
- ``version`` is the package version see :pep:`440` for more details on
101
100
versions.
102
101
- ``author`` and ``author_email`` are used to identify the author of the
@@ -112,7 +111,7 @@ minimal set:
112
111
will just be a link to GitHub, GitLab, Bitbucket, or similar code hosting
113
112
service.
114
113
- ``packages`` is a list of all Python :term:`import packages <Import
115
-
Package>` that should be included in the :term:`distribution package`.
114
+
Package>` that should be included in the :term:`distribution package`.
116
115
Instead of listing each package manually, we can use :func:`find_packages`
117
116
to automatically discover all packages and subpackages. In this case, the
118
117
list of packages will be `example_pkg` as that's the only package present.
@@ -207,8 +206,8 @@ files in the :file:`dist` directory:
207
206
.. code-block:: text
208
207
209
208
dist/
210
-
example_pkg-0.0.1-py3-none-any.whl
211
-
example_pkg-0.0.1.tar.gz
209
+
example_pkg_your_username-0.0.1-py3-none-any.whl
210
+
example_pkg_your_username-0.0.1.tar.gz
212
211
213
212
.. note:: If you run into trouble here, please copy the output and file an issue
214
213
over on `packaging problems`_ and we'll do our best to help you!
@@ -259,21 +258,14 @@ PyPI. After the command completes, you should see output similar to this:
259
258
Uploading distributions to https://test.pypi.org/legacy/
0 commit comments