Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make "setup.py bdist_egg" to ignore specific source files?

I'm trying to build a package for a django application, but excluding all tests modules. I have tried setting

exclude = ["*.tests", "*.tests.*", "tests.*", "tests"]

on find_packages and defining a MANIFEST.in, but the tests are always compiled and included in the bundle.

Any clues?

like image 566
Marcio Cruz Avatar asked Mar 15 '12 16:03

Marcio Cruz


People also ask

What is Package_dir in setup py?

package_dir = {'': 'lib'} in your setup script. The keys to this dictionary are package names, and an empty package name stands for the root package. The values are directory names relative to your distribution root.

What does setup py Sdist do?

(assuming you haven't specified any sdist options in the setup script or config file), sdist creates the archive of the default format for the current platform. The default format is a gzip'ed tar file ( . tar. gz ) on Unix, and ZIP file on Windows.

What is the command used for building a source distribution python setup py?

To build a source distribution, use the command line to navigate to the directory containing setup.py, and run the command python setup.py sdist.


1 Answers

I found the combination both adding find_packages rule and writing out MANIFEST.in rules i.e. prune tests

Note that for python 3.2 and older you must have __init__.py in tests root, for find_packages command to consider tests folder to be a package.

Sample find_packages exclude command in setup.py

 packages=find_packages(
    exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),

Sample MANIFEST.in

 include *.txt *.ini *.cfg *.rst
 recursive-include fmcc *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml
 prune tests
like image 60
Alex Volkov Avatar answered Oct 17 '22 09:10

Alex Volkov