[Distutils] Extending distutils with 3rd party build commands?

Bob Ippolito bob at redivi.com
Thu Oct 21 05:02:51 CEST 2004


On Oct 20, 2004, at 22:19, Phillip J. Eby wrote:

> At 01:09 AM 10/21/04 +0200, M.-A. Lemburg wrote:
>> Bob Ippolito wrote:
>>> On Oct 20, 2004, at 18:38, Bob Ippolito wrote:
>>>
>>>> On Oct 20, 2004, at 18:10, M.-A. Lemburg wrote:
>>>>
>>>>> Bob Ippolito wrote:
>>>>>
>>>>>> I've developed two bdist commands (bdist_pkg and bdist_mpkg) for 
>>>>>> usage on OS X.  These commands apply to any setup.py that 
>>>>>> supports an "install" command, similar to bdist_wininst, so it 
>>>>>> would be nice if every setup.py didn't have to explicitly import 
>>>>>> something in order to get the commands there.
>>>>>> I know I can make it work with a pth file that imports bdist_pkg, 
>>>>>> but that seems a bit costly to do because it will end up 
>>>>>> importing a bunch of stuff (distutils, mainly).
>>>>>> Is there another way to do it?
>>>>>
>>>>>
>>>>> Submit them for inclusion in the standard distribution ;-)
>>>>
>>>>
>>>> I will, for 2.5... but there's quite some time between now and then.
>>>
>>> Well I did find another way, thanks to PEP 302.
>>> How "evil" would it be if I had this module imported by a pth file?  
>>> It does do what I want it to do, but I'm not sure if it's safe to 
>>> inflict on users or not..
>>
>> Import hooks are bad. Avoid them if you can.
>>
>> What so bad in adding a sinlge import to all your setup.pys ?
>> That import could then trigger the installation of the new
>> command by importing distutils and tweaking the cmdclass
>> in distutils, e.g.
>>
>> import biDistutilsExtensions
>
> Another possibility: create a script that does the import, then calls 
> execfile() on 'setup.py' in the current directory, so that you can 
> just run that script instead of setup.py.  You can then install that 
> script, so users can run it against any setup.py.

Yeah, I guess that's the only reasonable thing to do until Python 2.5 :)

-bob



More information about the Distutils-SIG mailing list