[Zope3-dev] More thoughts on packaging

Phillip J. Eby pje at telecommunity.com
Fri Feb 13 17:28:37 EST 2004


At 05:03 PM 2/13/04 -0500, Fred Drake wrote:
>On Friday 13 February 2004 03:16 pm, Phillip J. Eby wrote:
>  > Suppose that we put dependency metadata in package directories as an
>  > extra file, and then we wrote a 'package.py' script that generates a
>  > custom 'setup.py' from the metadata, based on an intended target.  E.g.
>  > 'package.py sometarget'.
>
>+1
>
>  > The metadata could actually be provided in the form of a Python module
>  > (e.g. '__setup__.py')  that defines any extensions, datafiles, etc., as
>  > well as "provides" and "requires" keys.
>
>I'm not so sure this belongs in the same file as any Zope-specific
>information, but I'm not convinced that any of this is Zope-specific; it
>sounds very generally useful for any large collection of packages with
>varied dependency relationships.
>
>This is something I'd very much like to see in distutils anyway.

Yeah, for big packages it's often annoying to have to edit a central 
setup.py every time you add a subpackage or a data file.  Most of the time 
I forget during development, and don't discover the problem until somebody 
else tries to install the package.



>  > The 'package.py' script would write a 'setup.py' script that would look
>  > something like:
>  >
>  > execfile('setupstuff/prologue.py')
>  >
>  > gatherSetup('src/some/pkg1/__setup__.py')
>  > gatherSetup('src/other/something/__setup__.py')
>  >
>  > # ... etc, etc.
>  >
>  > execfile('setupstuff/epilogue.py')
>
>Why two execfile() calls instead of imports?

To avoid being at the mercy of what's installed on the Python path.  At 
least, that was the theory when I wrote setup extensions for some of my own 
apps.  Whether it really makes any sense or not, I don't know.  Mainly, it 
was because I was using a 'setup' directory, which meant that 'import 
setup' would've imported 'setup.py'.  So, I used execfile and went on with 
my life.  :)

That doesn't mean that Zope needs to emulate my hack, but until you asked 
the question I'd forgotten entirely why I chose to do it that way.  :)


>   If we're presuming the files
>are there, make setupstuff a module or package and use that.  So we end up
>with something more like:
>
>-------------------------------------------
>from setupstuff import setupFromDirectories
>
>setupFromDirectories([
>     'src/some/pkg1',
>     'src/other/something',
>     # ... etc.
>     ])
>-------------------------------------------

That's definitely a lot more compact.




More information about the Zope3-dev mailing list