[Distutils] using sub_commands in distutils

P.J. Eby pje at telecommunity.com
Fri May 14 20:27:43 CEST 2010


At 07:22 PM 5/14/2010 +0200, Manlio Perillo wrote:
>P.J. Eby ha scritto:
> > [...]
> >> I want messages to be compiled (using compile_catalog distutils command
> >> from babel) in all these cases:
> >> 1) create a binary distribution
> >> 2) create an egg
> >> 3) running the setup using develop command
> >>
> >>
> >> > [...]
> > [...]
> >> However I noted that running
> >>   python setup.py develop
> >>
> >> does not execute the compile_catalog command.
> >
> > Ah.  Okay, so yes, you'd need to subclass develop as well as bdist_egg.
>
>I have subclassed develop command:
>
>class develop(develop):
>     sub_commands = [('compile_catalog', None)] + develop.sub_commands
>
>cmdclass = dict(build=build, develop=develop),
>
>However compile_catalog is not called.

Develop doesn't have or run any subcommands; that's specific to the 
'build' command.  Any command you subclass, you'll have to 
investigate the source of to find out what it does and the best place 
to hook into it.


> > An easier way, however, might be to define aliases in setup.cfg:
> >
> > [alias]
> > develop = build_mo develop
> > bdist_egg = build_mo bdist_egg
>
>Thanks, this seems a good solution.
>I think I will use this.
>
>Note however that the configuration group is "aliases", not "alias".

Ah, yes, sorry.


>It is unfortunate that aliases are not executed internally.
>That is, I would really like to define an alias for the "build" command,
>and have it expanded when "build" command is called by other commands
>like "bdist".

Yeah, that could lead to other problems in the current distutils 
architecture.  A redesigned distutils system would hopefully have a 
better way to accomplish this.



More information about the Distutils-SIG mailing list