I am trying out the Pyramid tutorial example and it's built-in setup.py file appears to be set up to add static files to the egg file but it doesn't actually happen. I've done some search and toying with the settings but I'm unable to get the desired behavior.
include *.ini
include_package_data
is set to True
package_data
contains the entry: { '' : ['*.ini'] }'
It doesn't seem to matter what setting I change, there appears to be no effect. I should probably mention the desired files are listed in the SOURCES.txt file.
The files I'd like to have included are in the root of the distribution's directory (where setup.py resides).
What do I seem to be missing here?
The top level .ini files of pyramid are "non-package data files", i.e. there is no __init__.py
in the directory they reside. This somehow means that they will not be included in the egg archive generated with setup.py bdist_egg
, even if your conditions 1 and 2 are satisfied.
To include such "non-package data files", I think the cleanest way is to add them as data_files
to setup()
, e.g.
setup(
...
data_files=[
('', [
'development.ini',
'production.ini',
]),
],
zip_safe=False,
...
)
Then, the files will be included in the egg archive at the top level, retrievable with:
import os
import pkg_resources
dist = pkg_resources.get_distribution('MyApp')
config_file = os.path.join(dist.location, 'production.ini')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With