[Distutils] [PEAK] Dependencies before calling setup()

Timur Izhbulatov TimurIzhbulatov at oilspace.com
Wed Jul 4 15:14:45 CEST 2007


Phillip J. Eby wrote:
> At 06:16 PM 7/3/2007 +0400, Timur Izhbulatov wrote:
>> Hi all,
>>
>> I use Cheetah in my project and want to precompile templates in my 
>> project's setup.py. So, I need to have Cheetah installed *before* 
>> setup() is called.
> 
> Don't do that.  setup scripts must *never* perform such actions before 
> setup() is called.  What if someone is just running "setup.py --help", 
> after all?
> 
> NEVER do this.  easy_install's sandboxing code will also reject your 
> package as unsafe to run if you attempt something like this.

Oops. A dirty hack :(

>> I'm trying to use setuptools.command.easy_install.main(['Cheetah']) 
>> but I can't find any way to update sys.path after that. Is there any 
>> 'official' way to do this?
> 
> The official way to require that a package is available during setup() 
> execution is viat the 'setup_requires' keyword, similar to the 
> 'install_requires' keyword.  If you need the same package in both 
> situations, you must list it in both keywords.
> 
> To actually do the precompile, you should subclass the install_data or 
> install_lib command, and override its run() method to do the 
> compilation, as well as doing whatever it did before.  You use the 
> 'cmdclass' keyword to setup() to pass in a dictionary mapping command 
> names to your subclass(es).
> 
> Your subclasses *must* honor the options they are given, and not attempt 
> to install anything except where they are told.  The options will be 
> available as attributes of the instance created by the distutils.

Thanks for the exhaustive explanation; it's very helpful.

Subclassing install_lib worked just fine.

Regards,
-- 
Timur Izhbulatov
OILspace, 26 Leninskaya sloboda, bld. 2, 2nd floor, 115280 Moscow, Russia
P:+7 495 105 7245 + ext.205 F:+7 495 105 7246 E:TimurIzhbulatov at oilspace.com
Building Successful Supply Chains - One Solution At A Time.
www.oilspace.com


More information about the Distutils-SIG mailing list