I'm kind of lost in all the locations you can add data files.
First, there is the MANIFEST.in
file. As I understand, this is only to specify source files to be included in "source distribution".
Then, there is the data_files
argument to setup()
function, where you list files that should be installed, but it's from the root (either /
, either ~user/.local
). And finally, there is package_data
that pretends to do what I want... But on a bdist, I don't see any difference with data_files
I have a data file, say "default_conf.cfg".
my MANIFEST.in
contains :
include default_conf.cfg
and my setup.py
:
setup(
# ...
package_data={
'': ['default_conf.cfg'],
}
)
When I do a ./setup.py sdist
, the file is included, same with ./setup.py bdist
(as expected)
However, if I try to install as editable package (pip install --user -e .
), I can't access it with pkg_resources.resource_string(__name__, 'default_conf.cfg')
What am I missing to be able to access it from any kind on distribution/install ?
(The documentation is quite verbose, and information are dispersed across several pages so it's easy to miss something.)
EDIT
I put my data file as a subdir of my module and it seems to be better :
my_pkg/
|-my_pkg/
| |-__init__.py
| |-data/
| | |-default_conf.cfg
|
|-setup.py
setup.py :
setup(
# ...
package_data={
'my_module': ['data/default_conf.cfg'],
}
)
However, when I try to pip install --user -e .
, the content of the .egg-link is /.../my_pkg/build/lib
instead of /.../my_pkg
, then of course, it is not live-editable... Why does setuptools use this path ?