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 setu
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.
Ug, setuptools makes this really tricky :(
I don't know if this is what you want, but one project I work on uses a combination of two things:
from setuptools import setup, find_packages
...
packages = find_packages(exclude=['tests']),
data_files = os.walk(path_to_files),
An additional solution that worked in my case. Apparently: packages=setuptools.find_packages(exclude=["tests.*", "tests"]),
didn't work, but:
packages=setuptools.find_packages(exclude=["*tests.*", "*tests"]),
adding the star character at the beginning of the word did the trick.
I have the following in my setup.py
...
setup(name='pyfoo',
version="1.0.2",
description='Example for stack overflow',
url='http://stackoverflow.com/',
author='David Michael Pennington',
author_email='mike /|at|\ pennington.net',
license='GPL',
platforms='any',
keywords='Stack Overflow Example',
entry_points = "",
long_description=read('README.rst'),
include_package_data=True, # Checks MANIFEST.in for explicit rules
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
packages=find_packages(),
use_2to3=True,
zip_safe=False,
setup_requires=["setuptools_hg"],
I had a doc/
directory that was getting massive due to the number of images I had in it; this meant that the size of my sdist
was growing over 500kB. Originally I had this in my MANIFEST.in
...
include LICENSE CHANGES README.rst requirements.txt
recursive-exclude * __pycache__
recursive-exclude * *.pyc
recursive-exclude * *.pyo
recursive-exclude * *.orig
The only thing I had to do to exclude my doc directory was this line at the bottom of MANIFEST.in
...
prune doc*
Using prune doc*
suddenly removed all my doc/
directory from the sdist
tarball. So, it looks like you just need to use this in a MANIFEST.in
file...
prune tests*
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.
For similar purpose, my collegue wrote setuptools-dummy package: http://github.com/ella/setuptools-dummy/tree/master
Take a look at setuptools_dummy, modify excludes to your needs and it should work. If not, open an issue ;)