[Chicago] Distributing doc files w/ distutils src pkg?

Kumar McMillan kumar.mcmillan at gmail.com
Mon Oct 29 17:10:32 CET 2007


On 10/27/07, skip at pobox.com <skip at pobox.com> wrote:
>     from distutils.core import setup
>     setup(name='lockfile',
>           author='Skip Montanaro',
>           author_email='skip <at> pobox.com',
>           maintainer='Skip Montanaro',
>           maintainer_email='skip <at> pobox.com',
>           url='http://www.webfast.com/~skip/python/',
>           download_url='http://www.webfast.com/~skip/python/lockfile.tar.gz',
>           version='0.1',
>           py_modules=['lockfile'],
>           data_files=[('doc', ['lockfile.rst'])],
>           )
>
> I've used the data_files arg to setup to note where the docs live.  Alas,
> the sdist command doesn't include this in the tar file:
>
>     % tar tfz dist/lockfile-0.1.tar.gz
>     lockfile-0.1/
>     lockfile-0.1/lockfile.py
>     lockfile-0.1/PKG-INFO
>     lockfile-0.1/README
>     lockfile-0.1/setup.py
>
> I'm a complete distutils novice.  I can't for the life of me understand why
> the doc directory isn't included in the tar file.  As far as I can tell
> distutils has no explicit provision at all for distributing documentation,
> which seems very weird.  What am I missing?

I believe you need to add "include" statements to the MANIFEST.in
*even though* you declared the data_files keyword.  I forget why
exactly, but I've banged my head on this a few times since
"data_files" seems like it should do that for you automatically.

http://docs.python.org/dist/manifest.html

I have this hack in a setup file I recently had to get it working for:

from setuptools import setup, find_packages
manf = open(os.path.join(os.path.dirname(__file__), "MANIFEST.in"), 'w')
print "updating %s" % manf.name
for sfile in find_package_data(absolute=True):
    manf.write("include %s\n" % sfile)
manf.close()


(without setuptools you can roll your own find_package_data() with
some recursive globs)

-Kumar


More information about the Chicago mailing list