I am building and shipping a Python library in which I need to have a template file (xml) available to edit and write on disk later.
Let's say, I have my template.xml
in my package directory.
I read there is two approaches:
- Have a
MANIFEST.in
withinclude mypackage/template.xml
- Specify in
setup.py
:package_data={'mypackage': ['template.xml']}
In both case, I kept the option include_package_data=True
.
Apparently, the file is put into the egg.
I am then building my library using sdist
distribution and releasing on pypi
(this is done in Travis).
But apparently my file is not installed. Or at least I don't find it.
To get the file, I tried to do:
xml_template = pkg_resources.resource_filename('mypackage', 'template.xml')
leading to
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.7/site-packages/mypackage/template.xml'
What should I do?