[Distutils] setuptools, eggs, and setup.py in the root of a package - how?

Phillip J. Eby pje at telecommunity.com
Wed Aug 8 03:51:08 CEST 2007

At 07:23 PM 8/7/2007 -0600, Jeff Shell wrote:
>So we've never done much with eggs or distutils up until now at my
>company. We've generally worked in Zope. We generally check out Python
>packages directly into a directory where Zope would automatically pick
>them up. So we've never gotten into any convention of having a layout
>that I commonly see these days:
>     distroot
>       - setup.py
>       + src
>          + ourlib
>            - __init__.py
>            - etc...
>Fearing that we'd have to dramatically change our source code around,
>and shake up existing checkouts, I've avoided trying to add any
>distutils/setuptools support to these packages. But I was told
>recently that I could have `setup.py` in the package root (`ourlib` in
>the example above).

You can, but putting it one level higher (e.g. 'src') would be much 
better.  Putting it inside the package means you can't get the 
"develop" or "test" commands to work correctly...  as you mention below.

>  I've seen this work in a plain distutils system
>(Chris McDonough's BuildIt), but I've had a nightmare of a time
>getting it to work with setuptools and zc.buildout and on and on.
>Some code lies below that tries to explain the dilemma and shows my
>best guess efforts so far. Has anyone had any success with this
>I was trying to use this as a 'develop' egg(?) using `zc.buildout`,
>and it doesn't work. In a generated 'virtual-python' kind of thing, it
>sets up this in sys.path (when specifying ``develop=src/ourlib`` in
>     sys.path[0:0] = [
>       '/Users/jshell/Documents/Programming/eggify/src/fdlib',
>       ...
>This seems like an uphill battle. Any tips?

"develop" won't work unless your project directory contains packages; 
i.e., setup.py has to be in "src" for this to work.  That's because 
some directory needs to get put in sys.path, that has both the 
.egg-info/ dir and the actual packages as subdirectories.

More information about the Distutils-SIG mailing list