Install python egg in creation environment including data files

This question assumes that the python package I want to install is a django application that includes templates and media files. But the question is valid for any python package that contains not only .py files.

I use buildout to create a tunable environment in which I am developing a django project. My buildout.cfg looks like this:

 [buildout] parts = python eggs = normal-python-package python-package-with-data-files find-files = http://domain-to-python-package-with-data-files [python] recipe = zc.recipe.egg interpreter = python eggs = ${buildout:eggs} 

(and some things related to django). python-package-with-data-files is available at the link at http://domain-to-python-package-with-data-files .

The eggs normal-python-package and python-package-with-data-files successfully installed in the eggs/ directory. Since python-package-with-data-files set zip_safe to False in its setup.py , it can be unzipped in eggs/ .

In the unpacked egg in eggs/ only python-package-with-data-files .py python-package-with-data-files not available (they are included in the .tar.gz package, available at http://domain-to-python-package-with-data-files )

How to make these data files be included in the egg? Do I need to modify the setup.py package setup.py ? Or is it related to construction?

What I found out is the following:

If I create the python setup.py sdist root directory python setup.py sdist in python-package-with-data-files , all data files are included in the created .tar.gz file. But if I create python setup.py bdist , this will lead to creation without using data files.

This makes me think that the problem is not related to a specific construction. But perhaps there is a way to tell buildout not to create a bdist , but sdist to create an egg and install the package in the project.

What should I do? I support python-package-with-data-files , so you can change setup.py if necessary.

+4
source share
1 answer

It looks like you need to use the package_data keyword argument in the setup.py file, so distutils knows that these files must be installed with your package.

+3
source

Source: https://habr.com/ru/post/1301696/


All Articles