Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding a top-level directory from a setuptools package

I'm trying to put a Python project into a tarball using setuptools. The problem is that setuptools doesn't appear to like the way that the source tree was originally setup (not by me, I must add). Everything that I actually want to distribute is in the top-level directory, rather than in a subdirectory like the setuptools docs talk about.

The tree has a directory, tests, that I don't want to have in the released package. However, using exclude_package_data doesn't seem to actually do any excluding, and I'd like to work out what I've done wrong.

My setup.py looks like this, in relevant part:

setup(   name="project",   packages=[''],   include_package_data=True,   exclude_package_data={'': ['tests']},   test_suite='nose.collector', ) 
like image 500
womble Avatar asked Mar 04 '09 00:03

womble


People also ask

What is setuptools package in Python?

Setuptools is a collection of enhancements to the Python distutils that allow developers to more easily build and distribute Python packages, especially ones that have dependencies on other packages. Packages built and distributed using setuptools look to the user like ordinary Python packages based on the distutils .

Does pip depend on setuptools?

In Fedora, our pip package Recommends setuptools. Practically that means: Majority of users who install pip will get setuptools by default. Users can explicitly uninstall setuptools after installing pip or exclude setuptools when installing pip.

Does Python include setuptools?

the setuptools is not part of the python vanilla codebase, hence not a vanilla modules. python.org installers or mac homebrew will install it for you, but if someone compile the python by himself or install it on some linux distribution he may not get it and will need to install it by himself.

What is setup CFG Python?

setup. cfg is a cheekily named Python package which supports providing all of a Python distribution's metadata and build configuration via the setup. cfg file at the base of the distribution's source tree, rather than in the setup.py script. The standard setup.py script is reduced to a stub which uses the setup.


2 Answers

We use the following convention to exclude 'tests' from packages.

setup(    name="project",    packages=find_packages(exclude=("tests",)),    include_package_data=True,     test_suite='nose.collector', ) 

We also use MANIFEST.in to better control what include_package_data=True does.

like image 63
flexiondotorg Avatar answered Sep 23 '22 14:09

flexiondotorg


I have wasted several hours on the same problem, trying to exclude a module, I finally found that I had to remove the *.egg-info and build directories, that somehow retained the idea that the module had to be included.

like image 23
mok0 Avatar answered Sep 26 '22 14:09

mok0