Skip to content

Commit 54d4260

Browse files
authored
Merge pull request #1357 from abravalheri/init-in-packages
Clarify that packages don't need `__init__.py`
2 parents 184f13f + 46c4d04 commit 54d4260

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

source/tutorials/packaging-projects.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ Create the following file structure locally:
5454
The directory containing the Python files should match the project name. This
5555
simplifies the configuration and is more obvious to users who install the package.
5656

57-
:file:`__init__.py` is required to import the directory as a package,
58-
even if as is our case for this tutorial that file is empty.
57+
:file:`__init__.py` is recommended to import the directory as a regular package,
58+
even if as is our case for this tutorial that file is empty [#namespace-packages]_.
5959

6060
:file:`example.py` is an example of a module within the package that could
6161
contain the logic (functions, classes, constants, etc.) of your package.
@@ -535,3 +535,15 @@ some things you can do:
535535
:ref:`pdm`, and :ref:`poetry`.
536536
* Read :pep:`517` and :pep:`518` for background and details on build tool configuration.
537537
* Read about :doc:`/guides/packaging-binary-extensions`.
538+
539+
540+
----
541+
542+
.. rubric:: Notes
543+
544+
.. [#namespace-packages]
545+
Technically, you can also create Python packages without an ``__init__.py`` file,
546+
but those are called :doc:`namespace packages </guides/packaging-namespace-packages>`
547+
and considered an **advanced topic** (not covered in this tutorial).
548+
If you are only getting started with Python packaging, it is recommended to
549+
stick with *regular packages* and ``__init__.py`` (even if the file is empty).

0 commit comments

Comments
 (0)