In setup.py, I have specified package_data like this:
packages=['hermes'],
package_dir={'hermes': 'hermes'},
package_data={'hermes': ['templates/*.tpl']},
And my directory structure is roughly
hermes/
|
| docs/
| ...
| hermes/
|
| __init__.py
| code.py
| templates
|
| python.tpl
|
| README
| setup.py
The problem is that I need to use files from the templates directory in my source code so I can write out python code (this project is a parser generator). I can't seem to figure out how to properly include and use these files from my code. Any ideas?
__name__
instead specifying module name directly, thereforedata = pkg_resources.resource_string('hermes', 'templates/python.tpl')
becomesdata = pkg_resources.resource_string(__name__, 'templates/python.tpl')
– Aladdin