[PEAK] Dependencies before calling setup()
Phillip J. Eby
pje at telecommunity.com
Tue Jul 3 11:50:33 EDT 2007
At 06:16 PM 7/3/2007 +0400, Timur Izhbulatov wrote:
>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.
>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.
(Oh, and speaking of the distutils, the correct place for
discussion/support of setuptools is the distutils-SIG. Please direct
future correspondence there. Thanks.)
More information about the PEAK