[Distutils] recursive package_data (setuptools?)

Phillip J. Eby pje at telecommunity.com
Fri Sep 16 15:10:40 CEST 2005

At 05:55 PM 9/15/2005 -0500, Ian Bicking wrote:
>I have a nested directory with templates, like
>I thought I could include them in a package with:
>      package_data={
>        'mypackage': ['templates/*']})
>But it doesn't work -- while the package is fine, when installed
>setuptools (maybe just inheriting distutils here) tries to copy
>templates/admin over, and it can't copy a directory.  And, I assume, it
>won't even try templates/admin/bar.pt.
>So... is there a way to do this, without enumerating (a) every
>subdirectory I'm interested in, and (b) every extension I'm intersted in?

Write a function to do it for you?  :)

Seriously, it might not be a bad idea to add a 'find_package_data()' 
function along the lines of the sdist command's "include everything that's 
under source control" algorithm.  Then you could just do:

     package_data = find_package_data()

and be done with it.  We could perhaps have it use the actual sdist 
command's file finding code, so that MANIFEST.in is respected if you're not 
using source control.  It would need to filter out .py files and files that 
are not inside packages, and create a package_data mapping based on the 
nearest containing package.

More information about the Distutils-SIG mailing list