Skip to content

Commit baebc9d

Browse files
committed
docs: clarify packaging tutorial import and CLI scope
1 parent ded8541 commit baebc9d

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎source/tutorials/packaging-projects.rst‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ This tutorial walks you through how to package a simple Python project. It will
55
show you how to add the necessary files and structure to create the package, how
66
to build the package, and how to upload it to the Python Package Index (PyPI).
77

8+
The example is an **importable Python package**. If your main goal is to turn a
9+
Python program into an installed command such as ``my-tool``, start with the
10+
:doc:`command-line tools guide </guides/creating-command-line-tools>`. That
11+
guide covers executable entry points; you can then use the build and publishing
12+
steps from this tutorial for the resulting project.
13+
814
.. tip::
915

1016
If you have trouble running the commands in this tutorial, please copy the command
@@ -68,6 +74,19 @@ Open that file and enter the following content:
6874
def add_one(number):
6975
return number + 1
7076
77+
Because this tutorial leaves :file:`__init__.py` empty, ``add_one`` belongs
78+
to the ``example`` module rather than being exposed directly on the package.
79+
After installation, use it through that module, for example:
80+
81+
.. code-block:: pycon
82+
83+
>>> from example_package_YOUR_USERNAME_HERE import example
84+
>>> example.add_one(2)
85+
3
86+
87+
A package can choose to re-export selected names from :file:`__init__.py`,
88+
but doing so is an API-design choice and is not required for packaging.
89+
7190
If you are unfamiliar with Python's :term:`modules <Module>` and
7291
:term:`import packages <Import Package>`, take a few minutes to read over the
7392
`Python documentation for packages and modules`_.

0 commit comments

Comments
 (0)