[Distutils] Making commands extensible by default
Tarek Ziadé
ziade.tarek at gmail.com
Thu Apr 9 22:30:20 CEST 2009
Hello,
This is a side discussion but quiet important ihmo.
== Problem ==
Some people complained about the fact that is was hard to extend
Distutils commands.
You end up rewriting the whole command most of the time.
So what's a command ? It's a class that is used by the distribution
instance when you run Distutils.
roughly:
cmd = Command(distribution)
cmd.initialize_options()
cmd.finalize_options() <--- allows to check the options if
subcommands where run
cmd.run() <--- runs the code
each command can define sub commands, but most of the time it's a
harcoded list, so you need to inherit the command
if you want to add a new behavior.
== work in progress, ==
What we want to do here is being able to define subsets in run(),
sharing the same options environment.
so basically, a rough, generic run() method could be:
def run():
for func in some_funcs:
func(self, options)
If "some_funcs" could be defined by a registery with simple names,
anyone could provide new functions
and configure the registery to run a sequence of function.
Given a command name, Distutils can get this list of function, through
a registery.
Each function could register itself into Distutils, like in what I
have started to work here for the manifest file:
see http://wiki.python.org/moin/Distutils/ManifestPluginSystem
The ordering would be configurable through the setup.cfg file.
Any opinion, idea for this part ?
Cheers
Tarek
More information about the Distutils-SIG
mailing list