summaryrefslogtreecommitdiff
path: root/docs/userguide
diff options
context:
space:
mode:
authorSaniya Maheshwari <saniya.mah@gmail.com>2022-05-31 17:37:13 +0530
committerSaniya Maheshwari <saniya.mah@gmail.com>2022-05-31 17:37:13 +0530
commit3854a8ddf196f01376d2ed5df7466c4717b3bf54 (patch)
treed8e494f8ce75d62286da123da03c6b46b24da1d9 /docs/userguide
parent6c3c88420c2c9c5a9081c591fbec15782b29d77c (diff)
downloadpython-setuptools-git-3854a8ddf196f01376d2ed5df7466c4717b3bf54.tar.gz
Added an `include_package_data` snippet to the subdirectory example
Just to make it clear that we can use either one of `package_data` or `include_package_data` and not just the former.
Diffstat (limited to 'docs/userguide')
-rw-r--r--docs/userguide/datafiles.rst48
1 files changed, 46 insertions, 2 deletions
diff --git a/docs/userguide/datafiles.rst b/docs/userguide/datafiles.rst
index 8f0b18bf..e8b7505d 100644
--- a/docs/userguide/datafiles.rst
+++ b/docs/userguide/datafiles.rst
@@ -314,8 +314,8 @@ Here, the ``.rst`` files are placed under a ``data`` subdirectory inside ``mypkg
while the ``.txt`` files are directly under ``mypkg``.
In this case, the recommended approach is to treat ``data`` as a namespace package
-(refer `PEP 420 <https://www.python.org/dev/peps/pep-0420/>`_). The configuration
-might look like this:
+(refer `PEP 420 <https://www.python.org/dev/peps/pep-0420/>`_). With ``package_data``,
+the configuration might look like this:
.. tab:: setup.cfg
@@ -370,6 +370,50 @@ which enables the ``data`` directory to be identified, and then, we separately s
files for the root package ``mypkg``, and the namespace package ``data`` under the package
``mypkg``.
+With ``include_package_data`` the configuration is simpler: you simply need to enable
+scanning of namespace packages in the ``src`` directory and the rest is handled by Setuptools.
+
+.. tab:: setup.cfg
+
+ .. code-block:: ini
+
+ [options]
+ packages = find_namespace:
+ package_dir =
+ = src
+ include_package_data = True
+
+ [options.packages.find]
+ where = src
+
+.. tab:: setup.py
+
+ .. code-block:: python
+
+ from setuptools import setup, find_namespace_packages
+ setup(
+ # ... ,
+ packages=find_namespace_packages(where="src"),
+ package_dir={"": "src"},
+ include_package_data=True,
+ )
+
+.. tab:: pyproject.toml (**EXPERIMENTAL**) [#experimental]_
+
+ .. code-block:: toml
+
+ [tool.setuptools]
+ # ...
+ # By default, include-package-data is true in pyproject.toml, so you do
+ # NOT have to specify this line.
+ include-package-data = true
+
+ [tool.setuptools.packages.find]
+ # scanning for namespace packages is true by default in pyproject.toml, so
+ # you need NOT include the following line.
+ namespaces = true
+ where = ["src"]
+
Summary
=======