Search code examples
pythonsetuptoolspython-wheel

Python packaging: exclude directory from bdist_wheel


I have the following project structure:

.
├── docs
├── examples
├── MANIFEST.in
├── README.rst
├── setup.cfg
├── setup.py
└── myproject

I want to bundle my project into a wheel. For this, I use the following setup.py:

#!/usr/bin/env python

from setuptools import setup, find_packages

setup(name='myproject',
      version='1.0',
      description='Great project'
      long_description=open('README.rst').read(),
      author='Myself'
      packages=find_packages(exclude=['tests','test','examples'])
     )

When running python setup.py bdist_wheel, the examples directory is included in the wheel. How do I prevent this?

According to

Excluding a top-level directory from a setuptools package

I would expect that examples is excluded.


Solution

  • I solved the issue by using a suffixed star, examples*, i.e.:

    find_packages(exclude=['*tests','examples*'])
    

    (Note that I am writing '*tests' with a leading star,because I have test packages within each code package, as in myproject.mypackage.tests. Somehow the suffixed star seems to not be necessary if there is already a prefixed one)