Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including resources in a Python package using setup.py

Tags:

python

web

I'm working on a website project.

When I use setup.py and run setup.py build, the build script excludes all of the resources in my web site (basically all of the non python files). What am I doing wrong?

like image 200
101010 Avatar asked Jan 28 '26 05:01

101010


1 Answers

The most reliable way I've found to include extra files in a distribution using distutils is to provide a MANIFEST.in file. Place this file in the same directory as your setup.py and include in it the list of resource files you require. For example, your MANIFEST.in file might like this:

include resources/somefile.txt resources/*.png 
recursive-include resources/static *.png *.jpg *.css *.js

See the distutils documentation for more details.

Though I prefer the MANIFEST.in method, if you are using setuptools or distribute, have a look at this answer for an alternative method of doing the same thing.

like image 129
Mark Gemmill Avatar answered Jan 30 '26 21:01

Mark Gemmill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!