Search code examples
pythondistutilssetup.pyhidden-files

How to include hidden files in python distutils?


My package has a hidden directory I want to distribute as package data. I include the following in distutils.setup(...):

[...]
package_data={'mypkg': ['.hg/*']},
[...]

However this syntax does not work: when I run python setup.py install, the directory .hg is not included in the package. I believe the problem is in the directory name .hg, because if I replace .hg with hg, then the following will work as expected.

[...]
package_data={'mypkg': ['hg/*']},
[...]

Unfortunately the directory name has to be .hg for Mercurial to work. Is there a workaround to this issue?


Solution

  • Seems to work with setuptools (instead of distutils):

    package_data={'mypkg': ['../.git/*']}
    

    includes .git/* (non-recursive) in sdist, bdist_egg and bdist_wheel.