[Distutils] Distutils at the PyCon 2004 sprints

Phillip J. Eby pje at telecommunity.com
Wed Mar 17 17:57:39 EST 2004


At 05:22 PM 3/17/04 -0500, Fred L. Drake, Jr. wrote:

>- dependency support
>   (http://www.python.org/cgi-bin/moinmoin/DistutilsDependencies)
>
>   This is Phillip Eby's proposal for adding dependency support to
>   distutils, including automatic download and installation of required
>   packages.

FYI, the current implementation at http://cvs.eby-sarna.com/setuptools/ now 
includes a 'Require' class for specifying dependencies, and a 
'find_packages()' function to automatically locate packages in a given 
directory (so you don't have to list them individually), e.g.:

setup(
     name="setuptools",
     version="0.01",
     description="Distutils enhancements",
     author="Phillip J. Eby",
     author_email="peak at eby-sarna.com",
     license="PSF or ZPL",
     test_suite = 'setuptools.tests.test_suite',
     requires = [Require('Distutils','1.0.3','distutils')],
     packages = find_packages(),
)

The 'Require' class takes a package name, version, and a module to 
check.  It does not import the module (unless it's written in C), but 
rather uses a variety of sneaky tricks to do a version check.  By default, 
the attribute looked for is '__version__' and the version class used for 
comparisons is distutils' StrictVersion.  But you can override these 
defaults with keyword arguments.  'Require' objects can search a specified 
set of paths, so you can ensure that the target installation location is 
checked as well as the current sys.path.  To handle packages without an 
explicit version attribute, you can set the requested version to 'None', 
and specify an attribute (i.e. class, function, or other global) name that 
must be defined by the module.  There's a pretty extensive test suite that 
verifies all of these capabilities.

The implementation also includes a skeleton 'depends' command that's 
automatically run prior to 'install' if there are any Require's passed to 
setup().  Right now that command just prints a message to say that it's 
being run, but sometime before the weekend I'd like to upgrade it to halt 
the installation with a list of unresolved dependencies, if 
applicable.  I'll also add a 'homepage' keyword to 'Require', so that it 
can tell you where to go to manually find/download/install them.

The current version also provides transparent support for building Pyrex 
extensions; if you have '.pyx' source files in an extension, the '.c' 
version will automatically be used instead if Pyrex is not 
available.  Thus, you can easily distribute preprocessed '.c' versions for 
folks without Pyrex.

These features are in addition to those described in my previous post at:

http://mail.python.org/pipermail/distutils-sig/2004-March/003758.html


Fred, do you think we should go ahead and move setuptools to 
cvs.zope.org?  Actually, I guess first I should ask if you found its 
"features" mechanism useful for the sub-package dependency management you 
were prototyping for Zope X3.  :)




More information about the Distutils-SIG mailing list