Skip to content

Commit 85b1e66

Browse files
committed
Add examples for package_dir customisation
1 parent 74e5ced commit 85b1e66

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

docs/userguide/package_discovery.rst

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,50 @@ alongside the project code) are automatically filtered in the case of
115115
.. autoattribute:: setuptools.discovery.FlatLayoutModuleFinder.DEFAULT_EXCLUDE
116116

117117
Also note that you can customise your project layout by explicitly setting
118-
:doc:`package_dir <userguide/declarative_config>`.
118+
``package_dir``:
119+
120+
.. tab:: setup.cfg
121+
122+
.. code-block:: ini
123+
124+
[options]
125+
# ...
126+
package_dir =
127+
= lib
128+
# similar to "src-layout" but using the "lib" folder
129+
# pkg.mod corresponds to lib/pkg/mod.py
130+
# OR
131+
package_dir =
132+
pkg1 = lib1
133+
# pkg1.mod corresponds to lib1/mod.py
134+
# pkg1.subpkg.mod corresponds to lib1/subpkg/mod.py
135+
pkg2 = lib2
136+
# pkg2.mod corresponds to lib2/mod.py
137+
pkg2.subpkg = lib3
138+
# pkg2.subpkg.mod corresponds to lib3/mod.py
139+
140+
.. tab:: setup.py
141+
142+
.. code-block:: python
143+
144+
setup(
145+
# ...
146+
package_dir = {"": "pkg"}
147+
# similar to "src-layout" but using the "pkg" folder
148+
# mylib.mod corresponds to pkg/mylib/mod.py
149+
)
150+
151+
# OR
152+
153+
setup(
154+
# ...
155+
package_dir = {
156+
"pkg1": "lib1", # pkg1.mod corresponds to lib1/mod.py
157+
# pkg1.subpkg.mod corresponds to lib1/subpkg/mod.py
158+
"pkg2": "lib2", # pkg2.mod corresponds to lib2/mod.py
159+
"pkg2.subpkg": "lib3" # pkg2.subpkg.mod corresponds to lib3/mod.py
160+
# ...
161+
)
119162
120163
.. important:: Automatic discovery will **only** be enabled if you don't
121164
provide any configuration for both ``packages`` and ``py_modules``.

0 commit comments

Comments
 (0)