I'm trying to create a package with with a data file, but it's not working.
My setup.cfg (per link) is below.
[metadata]
name = my_package
version = 1.0.0
description = My package description
author = John Henckel
author_email = [email protected]
url = http://example.com
keywords = one, two
license = BSD 3-Clause License
classifiers =
Framework :: Django
License :: OSI Approved :: BSD License
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
[options]
include_package_data = True
packages = find:
[options.package_data]
* = *.txt
and the directory structure of my project is...
LICENSE
pyproject.toml
README.md
setup.cfg
my_package
hello.txt
__init__.py
and I typed...
python -m build --sdist
tar -vtf dist/my_package-1.0.0.tar.gz
and the output, as you can see does not contain the hello.txt. WHY NOT!??
drwxrwxrwx 0 0 0 0 Oct 22 17:28 my_package-1.0.0/
-rw-rw-rw- 0 0 0 48 Oct 22 17:24 my_package-1.0.0/LICENSE
-rw-rw-rw- 0 0 0 474 Oct 22 17:28 my_package-1.0.0/PKG-INFO
-rw-rw-rw- 0 0 0 29 Oct 22 17:24 my_package-1.0.0/README.md
drwxrwxrwx 0 0 0 0 Oct 22 17:28 my_package-1.0.0/my_package/
-rw-rw-rw- 0 0 0 0 Oct 22 17:24 my_package-1.0.0/my_package/__init__.py
drwxrwxrwx 0 0 0 0 Oct 22 17:28 my_package-1.0.0/my_package.egg-info/
-rw-rw-rw- 0 0 0 474 Oct 22 17:28 my_package-1.0.0/my_package.egg-info/PKG-INFO
-rw-rw-rw- 0 0 0 201 Oct 22 17:28 my_package-1.0.0/my_package.egg-info/SOURCES.txt
-rw-rw-rw- 0 0 0 1 Oct 22 17:28 my_package-1.0.0/my_package.egg-info/dependency_links.txt
-rw-rw-rw- 0 0 0 11 Oct 22 17:28 my_package-1.0.0/my_package.egg-info/top_level.txt
-rw-rw-rw- 0 0 0 108 Oct 01 13:52 my_package-1.0.0/pyproject.toml
-rw-rw-rw- 0 0 0 528 Oct 22 17:28 my_package-1.0.0/setup.cfg
I suspect that this might depend on which version of setuptools you have installed. When I build a test version of your package, using the same setup.cfg, my source distribution contains hello.txt. However, you may also want to try removing the include_package_data = True option from setup.cfg. The latest setuptools user guide says the following:
"In summary, the three options allow you to:
include_package_data
Accept all data files and directories matched by MANIFEST.in.package_data Specify additional patterns to match files that may or may not be matched by MANIFEST.in or found in source control.exclude_package_data Specify patterns for data files and directories that should not be included when a package is installed, even if they would otherwise have been included due to the use of the preceding options."It may be that, for some versions of setuptools, the include_package_data option overrides the package_data list so that you have to supply a MANIFEST.in file instead.
Edit: I overlooked this statement in the setuptools user guide, which seems to confirm what I wrote above:
"If using the setuptools-specific include_package_data argument, files specified by package_data will not be automatically added to the manifest unless they are listed in the MANIFEST.in file."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With