Skip to content

Commit 1a45c10

Browse files
authored
Clarify include/exclude in docs about package discovery (#3420)
2 parents da37f7b + 41e2d72 commit 1a45c10

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

docs/userguide/package_discovery.rst

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ all modules and packages meant for distribution are placed inside this
156156
directory::
157157
158158
project_root_directory
159-
├── pyproject.toml
160-
├── setup.cfg # or setup.py
159+
├── pyproject.toml # AND/OR setup.cfg, setup.py
161160
├── ...
162161
└── src/
163162
└── mypkg/
@@ -190,8 +189,7 @@ flat-layout
190189
The package folder(s) are placed directly under the project root::
191190
192191
project_root_directory
193-
├── pyproject.toml
194-
├── setup.cfg # or setup.py
192+
├── pyproject.toml # AND/OR setup.cfg, setup.py
195193
├── ...
196194
└── mypkg/
197195
├── __init__.py
@@ -240,8 +238,7 @@ A standalone module is placed directly under the project root, instead of
240238
inside a package folder::
241239
242240
project_root_directory
243-
├── pyproject.toml
244-
├── setup.cfg # or setup.py
241+
├── pyproject.toml # AND/OR setup.cfg, setup.py
245242
├── ...
246243
└── single_file_lib.py
247244
@@ -293,7 +290,7 @@ then returns a list of ``str`` representing the packages it could find. To use
293290
it, consider the following directory::
294291
295292
mypkg
296-
├── setup.cfg # and/or setup.py, pyproject.toml
293+
├── pyproject.toml # AND/OR setup.cfg, setup.py
297294
└── src
298295
├── pkg1
299296
│   └── __init__.py
@@ -320,7 +317,7 @@ in ``src`` that start with the name ``pkg`` and not ``additional``:
320317
[options.packages.find]
321318
where = src
322319
include = pkg*
323-
exclude = additional
320+
# alternatively: `exclude = additional*`
324321
325322
.. note::
326323
``pkg`` does not contain an ``__init__.py`` file, therefore
@@ -334,8 +331,7 @@ in ``src`` that start with the name ``pkg`` and not ``additional``:
334331
# ...
335332
packages=find_packages(
336333
where='src',
337-
include=['pkg*'],
338-
exclude=['additional'],
334+
include=['pkg*'], # alternatively: `exclude=['additional*']`
339335
),
340336
package_dir={"": "src"}
341337
# ...
@@ -353,8 +349,7 @@ in ``src`` that start with the name ``pkg`` and not ``additional``:
353349
354350
[tool.setuptools.packages.find]
355351
where = ["src"]
356-
include = ["pkg*"]
357-
exclude = ["additional"]
352+
include = ["pkg*"] # alternatively: `exclude = ["additional*"]`
358353
namespaces = false
359354
360355
.. note::
@@ -412,7 +407,7 @@ Now, suppose you decide to package the ``foo`` part for distribution and start
412407
by creating a project directory organized as follows::
413408
414409
foo
415-
├── setup.cfg # and/or setup.py, pyproject.toml
410+
├── pyproject.toml # AND/OR setup.cfg, setup.py
416411
└── src
417412
└── timmins
418413
└── foo
@@ -517,7 +512,7 @@ to `PEP 420 <https://www.python.org/dev/peps/pep-0420/>`_. It used to be more
517512
cumbersome to accomplish the same result. Historically, there were two methods
518513
to create namespace packages. One is the ``pkg_resources`` style supported by
519514
``setuptools`` and the other one being ``pkgutils`` style offered by
520-
``pkgutils`` module in Python. Both are now considered deprecated despite the
515+
``pkgutils`` module in Python. Both are now considered *deprecated* despite the
521516
fact they still linger in many existing packages. These two differ in many
522517
subtle yet significant aspects and you can find out more on `Python packaging
523518
user guide <https://packaging.python.org/guides/packaging-namespace-packages/>`_.
@@ -557,7 +552,7 @@ And your directory should look like this
557552
.. code-block:: bash
558553
559554
foo
560-
├── setup.cfg # and/or setup.py, pyproject.toml
555+
├── pyproject.toml # AND/OR setup.cfg, setup.py
561556
└── src
562557
└── timmins
563558
├── __init__.py
@@ -577,7 +572,7 @@ file contains the following:
577572
578573
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
579574
580-
The project layout remains the same and ``setup.cfg`` remains the same.
575+
The project layout remains the same and ``pyproject.toml/setup.cfg`` remains the same.
581576
582577
583578
----

0 commit comments

Comments
 (0)