Skip to content

Commit 11bdf83

Browse files
docs: Add descriptions for package_dir and packages find where
* package_dir is needed for both setup.cfg and setup.py * The where to look for packages is given under options.packages.find for setup.cfg, and is passed as the "where" arg to setuptools.find_package for setup.py * The terminology of "root package" comes from the old Distutils Examples docs (note that as of March 2021 these docs are still up as all the information in them has not yet been migrated to the setuptools docs) c.f. https://docs.python.org/3/distutils/examples.html#pure-python-distribution-by-package
1 parent d8f0dd3 commit 11bdf83

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

source/tutorials/packaging-projects.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,16 @@ an escape hatch when absolutely necessary.
188188

189189
In the options category, we have controls for setuptools itself:
190190

191+
- ``package_dir`` is a collection of package names and directories.
192+
An empty package name represents the "root package", so in this
193+
case the root package is in the ``src`` directory.
191194
- ``packages`` is a list of all Python :term:`import packages <Import
192195
Package>` that should be included in the :term:`Distribution Package`.
193196
Instead of listing each package manually, we can use the ``find:`` directive
194-
to automatically discover all packages and subpackages. In this case, the
195-
list of packages will be ``example_pkg`` as that's the only package present.
197+
to automatically discover all packages and subpackages and
198+
``options.packages.find`` to specify the ``package_dir`` to use. In this
199+
case, the list of packages will be ``example_pkg`` as that's the only
200+
package present.
196201
- ``python_requires`` gives the versions of Python supported by your
197202
project. Installers like pip will look back though older versions of
198203
packages until it finds one that has a matching Python version.
@@ -294,11 +299,15 @@ an escape hatch when absolutely necessary.
294299
which license your package is available under, and which operating systems
295300
your package will work on. For a complete list of classifiers, see
296301
https://pypi.org/classifiers/.
302+
- ``package_dir`` is a dictionary with package names for keys and directories
303+
for values. An empty package name represents the "root package", so in this
304+
case the root package is in the ``src`` directory.
297305
- ``packages`` is a list of all Python :term:`import packages <Import
298306
Package>` that should be included in the :term:`Distribution Package`.
299307
Instead of listing each package manually, we can use :func:`find_packages`
300-
to automatically discover all packages and subpackages. In this case, the
301-
list of packages will be ``example_pkg`` as that's the only package present.
308+
to automatically discover all packages and subpackages under ``package_dir``.
309+
In this case, the list of packages will be ``example_pkg`` as that's the
310+
only package present.
302311
- ``python_requires`` gives the versions of Python supported by your
303312
project. Installers like pip will look back though older versions of
304313
packages until it finds one that has a matching Python version.

0 commit comments

Comments
 (0)