1

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:

  1. Have a MANIFEST.in with include mypackage/template.xml
  2. 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?

Denis Rouzaud
  • 2,412
  • 2
  • 26
  • 45

1 Answers1

0

Apparently, removing include_package_data=True solved the issue.

I found the idea on this answer https://stackoverflow.com/a/33167220/1548052 But there is no explanation why.

Denis Rouzaud
  • 2,412
  • 2
  • 26
  • 45