[Distutils] using sub_commands in distutils

Manlio Perillo manlio_perillo at libero.it
Fri May 14 17:53:03 CEST 2010


P.J. Eby ha scritto:
> At 05:08 PM 5/14/2010 +0200, Manlio Perillo wrote:
>> Hi.
>>
>> In a package, I have gettext catalog messages, and I want to compile
>> them when the package is build.
>>
>> I looked at the Mercurial setup.py script, and what it does is:
>>
>> from distutils.command.build import build
>> build.sub_commands.insert(0, ('build_mo', None))
>>
>>
>> Is this the correct way?
> 
> No.  The correct way is to subclass the build command and use a cmdclass
> dictionary in the setup() call.  Something like:
> 
> from distutils.command.build import build
> class build(build):
>     sub_commands = [('build_mo', None)]+ build.sub_commands
> 

Ok, thanks.

By the way: in order to get messages compiled, should I just subclass
build and develop commands?


Regards  Manlio


More information about the Distutils-SIG mailing list