-1

I want to include a config file config.conf in the root of a Python namespace package as a package data resource.

For example with the following project directory structure:

repository_root/
├── mynamespace/
│   └── mypackage/
│       ├── __init__.py
│       └── ...
├── config.conf
├── setup.cfg
└── ...

I have the following in setup.cfg:

[options.package_data]
mynamespace.mypackage = *.conf

But when I build a wheel with python -m build -w and I examine the content of the wheel the file config.conf is not included in the .whl zipped wheel archive.
Also if I create a source distribution with python setup.py sdist then again the file is not included in the tar.gz archive.

If the config.conf is placed under mypackage as in the following:

repository_root/
├── mynamespace/
│   └── mypackage/
│       ├── __init__.py
│       └── config.conf
└── ...

Then config.conf is included in the wheel.

So how to include a file in the package root?

Later on, I noted that adding a MANIFEST.in file with:

include config.conf

Does result in the file being correctly included in the tar.gz when a source distribution is created with python setup.py sdist when it is located in repository_root.
But the file is still not included in a wheel built via python -m build -w.

Ricibob
  • 7,505
  • 5
  • 46
  • 65
  • 1
    I guess the location of the file should be `repository_root/mynamespace/fish.txt`. Then in `MANIFEST.in` there should be `include mynamespace/fish.txt` and in `setup.cfg` there should be `include_package_data = True` in the `[options]` section. https://setuptools.pypa.io/en/latest/userguide/datafiles.html – sinoroc Aug 23 '23 at 16:49

0 Answers0