[Distutils] Help to create a setup.py (subdirectories aren't working)

P.J. Eby pje at telecommunity.com
Thu Mar 25 03:37:18 CET 2010

At 11:04 PM 3/24/2010 -0300, Hugo Doria wrote:
>Hi guys,
>I am new to distutils and trying to create a setup.py for a project,
>but i am having a problem.
>My project has this directory layout:
>/myproject (binary)
>Here's the setup.py that i did:
>from distutils.core import setup
>DATAFILES = [('/usr/share/man/man1', ['doc/manpage.1']),
>       version='0.1',
>       license='GPL2',
>       description='Trying distutils,
>       author=['Hugo Doria'],
>       package_dir={'modules':MyProject/modules', 
> 'output':'MyProject/output'},
>       packages=['modules', 'output'],
>       scripts=['myproject'],
>       data_files=DATAFILES)
>When i run setup.py install it does works. But i get this on my system:
>It's a bit strange, is not?

It's exactly what you asked for.  Your setup.py says you have two 
top-level packages called 'modules' and 'output', so that's what you got.

>Shouldn't it be something like:
>What am i doing wrong?

You're using a package_dir with more than one entry in it, which is a 
sign that your project's layout is broken.  If you wanted a layout 
like the one you describe here, you need to:

1. Omit the package_dir option altogether
2. set packages = ['MyProject', 'MyProject.output', 'MyProject.modules']
3. Add an __init__.py in the MyProject directory, to make it the parent package

More information about the Distutils-SIG mailing list