[Distutils] Setting distutils options from sitecustomize
Ronald Oussoren
ronaldoussoren at mac.com
Mon Jan 23 20:16:43 CET 2006
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 at colorstudy.com / http://blog.ianbicking.org
> _______________________________________________
> Distutils-SIG maillist - Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig
More information about the Distutils-SIG
mailing list