[Distutils] packages and modules together

M.-A. Lemburg mal@lemburg.com
Thu Feb 27 16:25:34 2003

Fred L. Drake, Jr. wrote:
> Here's a topic that's come up before.
> Distutils does not currently support having both packages and modules
> in the same call to distutils.core.setup().  While this is probably
> fine for many projects, others have been bitten by it; Anthony Baxter
> asked about this just last month:
> http://mail.python.org/pipermail/distutils-sig/2003-January/003151.html
> We're increasingly using distutils with Zope, and would like to make
> our use of it as "clean" as possible.  The current setup script I'm
> working with has to call distutils.core.setup() three times, which is
> just too many for me.  Some of this can probably be improved by
> adjusting more of the provided knobs more carefully, but the simple
> use of both modules and packages seems like aviodable pain.
> Is there any reason not to support both in the distutils core
> directly?  While the limitation can be worked around, it seems
> gratuitous, and shouldn't need the extra machinations.

This seems to be related to some design decision in build_py.py
which is not clear at all:

         # Two options control which modules will be installed: 'packages'
         # and 'py_modules'.  The former lets us work with whole packages, not
         # specifying individual modules at all; the latter is for
         # specifying modules one-at-a-time.  Currently they are mutually
         # exclusive: you can define one or the other (or neither), but not
         # both.  It remains to be seen how limiting this is.

         # Dispose of the two "unusual" cases first: no pure Python modules
         # at all (no problem, just return silently), and over-specified
         # 'packages' and 'py_modules' options.

         if not self.py_modules and not self.packages:
         if self.py_modules and self.packages:
             raise DistutilsOptionError, \
                   "build_py: supplying both 'packages' and 'py_modules' " + \
                   "options is not allowed"

         # Now we're down to two cases: 'py_modules' only and 'packages' only.
         if self.py_modules:

I believe that a simple change to the .find_all_modules()
method would solve the problem: the method would need to merge
the two generated lists (from py_modules and the modules from
the packages).

Marc-Andre Lemburg

Professional Python Software directly from the Source  (#1, Feb 27 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
Python UK 2003, Oxford:                                     33 days left
EuroPython 2003, Charleroi, Belgium:                       117 days left