Is it possible to include subdirectories using dist utils (setup.py) as part of package data?

xamox picture xamox · Jun 7, 2012 · Viewed 24.6k times · Source

Basically my python package is setup like:

module
\_examples
  \_folder1
     \_file1.py
     \_file2.py
  \_folder2
    \_file1.py
    \_file2.py

Basically I want to just use:

package_data  = { 
            'module': ['examples/*'],
  },

because my project always has people adding examples and I want it to be easy to list them from within my application. I can get it work for any FILE within examples, but not re-curse down through sub-directories. Is this possible?

Answer

defermat picture defermat · Mar 16, 2014

I believe what you're looking for is something like this for you setup.py, which will recursively find any packages in the project, also be sure and include __init__.py files to subdirectories for each package you want.

from setuptools import setup, find_packages

setup(name='MySoftware',
      packages=find_packages()
)