[BUG] `[options.package_data]` in setup.cfg does nothing
See original GitHub issuesetuptools version
57.0.0
Python version
3.9.5
OS
Arch
Additional environment information
No response
Description
I have this project: https://gitlab.com/greyltc/runpanel/-/tree/a93fac114f5443dc5ae55b9a8eb395b3244e282b
It has a setup.cfg file with
[options]
include_package_data = True
and
[options.package_data]
runpanel = *.yaml
As you can see from the repo there, there’s a system_config.yaml
file present that I expect to be included as package data. But after I install the package, and run
import importlib.resources
list(importlib.resources.contents('runpanel'))
I get only ['__pycache__', '__init__.py', '__main__.py', 'app.py', 'sysdbus.py']
. There’s no yaml file.
Expected behavior
I expect that when I follow the packaging docs for including package_data files here: https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html?highlight=package_data that data should make it into my package.
How to Reproduce
- Install my project here https://gitlab.com/greyltc/runpanel/-/tree/a93fac114f5443dc5ae55b9a8eb395b3244e282b
- Notice that there are no .yaml package data files included
Output
$ ipython
In [1]: import importlib.resources
...: list(importlib.resources.contents('runpanel'))
Out[1]: ['__pycache__', '__init__.py', '__main__.py', 'app.py', 'sysdbus.py']
Code of Conduct
- I agree to follow the PSF Code of Conduct
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
python - How to include package data with setuptools/distutils?
Starting with setuptools 30.3.0 (released 2016-12-08), you can keep your setup.py very small and move the configuration to a setup.cfg file.
Read more >setup.py vs setup.cfg in Python - Towards Data Science
cfg is an ini file, containing option defaults for setup.py commands. You can pretty much specify every keyword we used in the setup.py...
Read more >Data Files Support - Setuptools - Python Packaging Authority
However, only mypkg1 has .rst data files. In such a case, if you want to use the package_data option, the following configuration will...
Read more >Simple documentation for setup.cfg - Discussions on Python.org
I was using “data files” as a generic term, just meaning “files containing data which my package needs”. It looks like I need...
Read more >A Practical Guide to Using Setup.py - GoDataDriven
using pip install scikit-learn , while you use it by importing from sklearn . The version of your package. This is the version...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry if that is confusing in the docs: https://setuptools.pypa.io/en/latest/userguide/datafiles.html
Both
include_package_data
andpackage_data
will only work with files inside the package directory (not the root of the project).Thank you very much for this explanation, and thanks for everything you’re doing to make packaging easier.
Re the docs, at the top of the page it says this:
But that did not work for me. The only thing that worked, and it worked on its own (without either
include_package_data
orMANIFEST.in
), wasoptions.package_data
.I am using only
setup.cfg
, with only the package name being set insetup.py
, so I’m not 100% certain I’m mapping the advice on this page (which all seems to usesetup()
) to my situation.I need to look at
setuptools_scm
… I have not been paying attention to it.