5

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.

Community
  • 1
  • 1
Bananach
  • 2,016
  • 26
  • 51
  • Try to add `examples/` to `.gitignore`. And maybe you then should add `setup(..., include_package_data=True, ...)`. – Roman Alexeev Apr 12 '17 at 10:17
  • 2
    I do not want to exclude examples/ from the repository. Also, why should I include_package_data? is that related to my question? – Bananach Apr 12 '17 at 10:42

1 Answers1

3

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)

Bananach
  • 2,016
  • 26
  • 51