Tarek Ziadé wrote:
> 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 ?
> 
Have you looked at paver?  It's syntax makes extension easy.

@task
def run():
    function1()
    function2()
    function3()

or
@task
@needs([function1, function2, function3])
def run():
    pass

So if I want to do everything that setuptools.command.install does and
also install locale files using my own function I do:

@task
def install_locales():
    # My code to install locales goes here
    pass

@task
def install():
    # A new install task that overrides the system install task
    # Note that I control ordering just by changing the order
    # subtasks get called
    call_task('setuptools.command.install')
    call_task('install_locales')

-Toshio

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to