pypa / packaging-problems

An issue tracker for the problems in packaging
151 stars 34 forks source link

adding DataFiles to wheel with build and pyproject.toml #637

Closed MatthewRalston closed 1 year ago

MatthewRalston commented 1 year ago

OS version

Arch 6.0.12

Python version

3.10.1

Pip version

22.3.1

Guide link

https://setuptools.pypa.io/en/latest/userguide/datafiles.html

Problem description

Switching from legacy setup.py to pyproject.toml has changed my ability to add plain text files along with my codebase.

For example, in the past with setup.py:

setup(
...
        package_data={'kmerdb': ['CITATION.txt']},
)

with pyproject.toml, I cannot discover my citation plaintext file with python -m build on pyproject.toml


[tool.setuptools]
include-package-data = true
packages = ['kmerdb']

[tool.setuptools.package-data]
citation = ["CITATION.txt"]

Error message

No response

abravalheri commented 1 year ago

Hi @MatthewRalston , with python -m build a sdist is created first and then a wheel is created from the sdist.

Can you confirm the CITATION.txt file is correctly added to the sdist? If it is not, you might want to use a plugin that does that automatically for you, like setuptools-scm or manually set it uo via MANIFEST.in.

abravalheri commented 1 year ago

Also note that the key in the [tool.setuptools.package-data] (left hand side of the =) needs to be an existing package with the files that you list contained by that package.

MatthewRalston commented 1 year ago

I can confirm that it is not added to the sdist:

* Building sdist...
Warning: 'keywords' should be a list, got type 'tuple'
/storage/data/scratch/build-env-o6h9cdss/lib/python3.10/site-packages/setuptools/_distutils/dist.py:265: UserWarning: Unknown distribution option: 'library_dirs'
  warnings.warn(msg)
/storage/data/scratch/build-env-o6h9cdss/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
  warnings.warn(msg, _BetaConfiguration)
running sdist
running egg_info
writing kmerdb.egg-info/PKG-INFO
writing dependency_links to kmerdb.egg-info/dependency_links.txt
writing entry points to kmerdb.egg-info/entry_points.txt
writing requirements to kmerdb.egg-info/requires.txt
writing top-level names to kmerdb.egg-info/top_level.txt
reading manifest file 'kmerdb.egg-info/SOURCES.txt'
adding license file 'LICENSE.txt'
writing manifest file 'kmerdb.egg-info/SOURCES.txt'
running check
creating kmerdb-0.7.2
creating kmerdb-0.7.2/kmerdb
creating kmerdb-0.7.2/kmerdb.egg-info
creating kmerdb-0.7.2/test
copying files to kmerdb-0.7.2...
copying LICENSE.txt -> kmerdb-0.7.2
copying README.md -> kmerdb-0.7.2
copying pyproject.toml -> kmerdb-0.7.2
copying setup.cfg -> kmerdb-0.7.2
copying setup.py -> kmerdb-0.7.2
copying kmerdb/__init__.py -> kmerdb-0.7.2/kmerdb
copying kmerdb/__main__.py -> kmerdb-0.7.2/kmerdb
copying kmerdb/config.py -> kmerdb-0.7.2/kmerdb
copying kmerdb/fileutil.py -> kmerdb-0.7.2/kmerdb
copying kmerdb/index.py -> kmerdb-0.7.2/kmerdb
copying kmerdb/kmer.py -> kmerdb-0.7.2/kmerdb
copying kmerdb/parse.py -> kmerdb-0.7.2/kmerdb
copying kmerdb/probability.py -> kmerdb-0.7.2/kmerdb
copying kmerdb/python_distances.py -> kmerdb-0.7.2/kmerdb
copying kmerdb/seqparser.py -> kmerdb-0.7.2/kmerdb
copying kmerdb/util.py -> kmerdb-0.7.2/kmerdb
copying kmerdb.egg-info/PKG-INFO -> kmerdb-0.7.2/kmerdb.egg-info
copying kmerdb.egg-info/SOURCES.txt -> kmerdb-0.7.2/kmerdb.egg-info
copying kmerdb.egg-info/dependency_links.txt -> kmerdb-0.7.2/kmerdb.egg-info
copying kmerdb.egg-info/entry_points.txt -> kmerdb-0.7.2/kmerdb.egg-info
copying kmerdb.egg-info/not-zip-safe -> kmerdb-0.7.2/kmerdb.egg-info
copying kmerdb.egg-info/requires.txt -> kmerdb-0.7.2/kmerdb.egg-info
copying kmerdb.egg-info/top_level.txt -> kmerdb-0.7.2/kmerdb.egg-info
copying test/test_kmer.py -> kmerdb-0.7.2/test
Writing kmerdb-0.7.2/setup.cfg
Creating tar archive
removing 'kmerdb-0.7.2' (and everything under it)
* Building wheel from sdist
MatthewRalston commented 1 year ago

Thank you @abravalheri , adding the correct package name to the left of the = solved the issue. Thanks.