Setting distutils options from sitecustomize
Has anyone tried anything that involves setting the distutils options (e.g., where to install libraries) from sitecustomize or some other Python location? I want to put in logic that is more complex than can be expressed in a configuration file. Setuptools-specific is a-ok too. Monkeypatching distutils doesn't particularly bother me in this case either. Though that's not great either (if it goes in sitecustomize), since it means that there's an overhead to every Python startup to load distutils and patch it, even if distutils wouldn't have otherwise loaded. Jim Fulton asked about something similar on IRC too -- actually about having an easy_install binary that installed to a different location than normal (to the Zope instance path). Similar in that however such a script might work it might need to do similar things, setting distutils options at runtime. -- Ian Bicking / ianb@colorstudy.com / http://blog.ianbicking.org
On 23-jan-2006, at 19:09, Ian Bicking wrote:
Has anyone tried anything that involves setting the distutils options (e.g., where to install libraries) from sitecustomize or some other Python location? I want to put in logic that is more complex than can be expressed in a configuration file. Setuptools-specific is a-ok too. Monkeypatching distutils doesn't particularly bother me in this case either. Though that's not great either (if it goes in sitecustomize), since it means that there's an overhead to every Python startup to load distutils and patch it, even if distutils wouldn't have otherwise loaded.
You could monkeypatch using .pth tricks. If you do this correctly the patch would only affect distutils. I've never used this in production, but something like this would work: - Create a directory (/FOOBAR) containing a directory distutils and an __init__.py inside that. The __init__.py should set its __path__ to include the real distutils package, execfile the real __init__.py and then do as much monkeypatching as it likes - Add a distutils-hacks.pth to site-packages that contains: import sys; sys.path.insert(0, "/FOOBAR") That way imports of distutils will get the monkeypatched version, without automagically importing distutils for each and every script. Extending distutils or setuptools to do what you need would probably be a much better solution :-) Ronald
Jim Fulton asked about something similar on IRC too -- actually about having an easy_install binary that installed to a different location than normal (to the Zope instance path). Similar in that however such a script might work it might need to do similar things, setting distutils options at runtime.
-- Ian Bicking / ianb@colorstudy.com / http://blog.ianbicking.org _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
At 12:09 PM 1/23/2006 -0600, Ian Bicking wrote:
Has anyone tried anything that involves setting the distutils options (e.g., where to install libraries) from sitecustomize or some other Python location? I want to put in logic that is more complex than can be expressed in a configuration file. Setuptools-specific is a-ok too.
The standard way to do this with the distutils would be to create custom versions of the commands, or subclass Distribution in order to slap in some extra configuration. For example, you could add to what configuration files get loaded. Of course, that doesn't help you much for affecting *other* people's setup scripts. :) Probably a way to do this in a future version of setuptools would be for me to add a lot more entry points that get run at various phases of a setup script's operation, like when the Distribution loads up configuration files or something.
Jim Fulton asked about something similar on IRC too -- actually about having an easy_install binary that installed to a different location than normal (to the Zope instance path).
A trivial way to do this currently would be to create a wrapper that changed the current directory to a directory with a custom setup.cfg in it, then ran easy_install. Another way would be to set the HOME environment variable instead, to point to a directory with a ".pydistutils.cfg" in it, although that might lead to other issues.
participants (3)
-
Ian Bicking
-
Phillip J. Eby
-
Ronald Oussoren