[Distutils] Installing single module from src directory

Dinu Gherman gherman at darwin.in-berlin.de
Wed Oct 1 14:10:04 CEST 2008


I've been using distutils for a while now, but today I'm running
into what seems to be the "minimal strange issue". I want to in-
stall a single Python module without anything else, no package
around it, which resides in a source subdirectory of the main
project directory. My layout looks like the following:

   Macintosh:Python dinu$ tree2.py -f mymodule
   |  setup.py
   |  src/
   |  |  mymodule.py

Now common sense says all I need to do is define the module in
setup.py like this:

   Macintosh:mymodule dinu$ more setup.py
   from distutils.core import setup

       py_modules = ["src/mymodule"],

Then, distutils does the following when running setup.py:

   Macintosh:mymodule dinu$ py252 setup.py build
   running build
   running build_py
   creating build
   creating build/lib
   creating build/lib/src
   copying src/mymodule.py -> build/lib/src

And of course, I get the following structure built:

   Macintosh:mymodule dinu$ tree2.py -f build
   |  lib/
   |  |  src/
   |  |  |  mymodule.py

And sure enough I don't want the "src" level. I can get rid
of it, but only after moving mymodule.py into the the main
project directory, and removing the "src/" in py_modules.

Instead, what I would *really* like is some smart combination
of setup parameters that would just do it. But so far, all my
efforts in finding combinations of py_modules, packages,
package_dir (dummy/fake package) and even package_data does
not do the trick. Now I'm desperately looking for a distutils
"Houdini" on this list.



More information about the Distutils-SIG mailing list