[Distutils] Adding a sub-command to the setup.py "build" and "develop" commands

P.J. Eby pje at telecommunity.com
Fri Mar 13 06:38:28 CET 2009


At 02:17 AM 3/13/2009 +0100, Brian Sutherland wrote:

>     http://pypi.python.org/pypi/van.potomo/
>
>However, one major problem is that to modify the function of the
>setup.py "build" and "develop" commands one needs to do this in the
>setup.py:
>
>     from setuptools import setup, find_packages
>     from van.potomo import develop, build
>
>     setup(
>         name = "HelloWorld",
>         cmdclass = {'build': build,
>                     'develop': develop},
>         setup_requires = ["van.potomo"],
>         version = "0.1",
>         packages = find_packages(),
>         )
>
>Meaning that you have to manually install van.potomo before tools like
>buildout can run the setup.py to figure out the dependencies. Is there
>any way to make that more automatic, especially so that buildout can
>have a chance?
>
> >From my experience with Debian, there's a "Build Dependencies" field in
>the control file where one can specify such things. I'm kindof hoping
>there's a setuptools equivalent?

You can use aliases to do this, sort of.  In your setup.cfg, do something like:

[aliases]
build = vp_build
develop = vp_develop

And then register these commands in the van.potomo package's entry 
points (i.e., as vp_build and vp_develop).

Unfortunately, this only works for *command-line commands* - it's not 
a general replacement for the commands, the way cmdclass is.

Probably a better solution would be to add the ability in setuptools 
to specify a *string* in cmdclass, instead of a class, so that this 
approach could work generally, instead of only on the command line.



More information about the Distutils-SIG mailing list