-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
When building a virtual environment, I'd like to be able to store
global distutils configuration options which are custom to that
environment. However, both setuptools and distutils expect to
read / write that file relative to the directory of
'distutils.__file__', which is located in the *source*
environment under virtualenv 0.8.4::
$ ~/projects/source/bin/virtualenv /tmp/virtual
New python executable in /tmp/virtual/bin/python
Installing setuptools.............done.
[/tmp]
$ cd /tmp/virtual/
[/tmp/virtual]
$ bin/python -c "import distutils; print distutils.__file__"
/home/tseaver/projects/source/lib/python2.4/distutils/__init__.pyc
The simplest way I can think of to make 'distutils.__file__'
local to the virtual environment is to make an empty local
'distutils' package, which pulls in the source version by hacking
'__path__'. However, because the virtual environment forces the
'real_prefix' library so high in the path, I also need to hack my
own library in higher (in 'sitecustomize.py')::
[/tmp/virtual]
$ patch -p1 < ../local_distutils.patch
patching file lib/python2.4/distutils/__init__.py
patching file lib/python2.4/sitecustomize.py
[/tmp/virtual]
$ bin/python -c "import distutils; print distutils.__file__"
/tmp/virtual/lib/python2.4/distutils/__init__.py
[/tmp/virtual]
Probably it would make more sense to fix the path in the SITE_PY
inside virtualenv's support-files; virtualenv could then just
make the near-empty local 'distutils' package with the correct
'__path__'.
I have attached the patch I used to fix up the local environment
('local_distutils.patch' in the example above).
Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 [EMAIL PROTECTED]
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFG+rc5+gerLs4ltQ4RAtySAKCR2RYNq/zJUnEAU/eNz5vsyYZ3ZgCeJ7lB
EO0xuEmqiLKZ86ZaK3CqfeU=
=r8N9
-----END PGP SIGNATURE-----
Make a local 'distutils' package, and point it back to the original, so
that we can store 'distutils.cfg' inside our environment. Then ensure that
our version gets found *first* when importing.
diff -rNu --exclude=site-packages bazbam/lib/python2.4/distutils/__init__.py foobar/lib/python2.4/distutils/__init__.py
--- bazbam/lib/python2.4/distutils/__init__.py 1969-12-31 19:00:00.000000000 -0500
+++ foobar/lib/python2.4/distutils/__init__.py 2007-09-26 15:11:49.000000000 -0400
@@ -0,0 +1,5 @@
+import os
+import sys
+__path__ = ['%s/lib/python2.4/distutils' % sys.prefix,
+ '%s/lib/python2.4/distutils' % sys.real_prefix,
+ ]
diff -rNu --exclude=site-packages bazbam/lib/python2.4/sitecustomize.py foobar/lib/python2.4/sitecustomize.py
--- bazbam/lib/python2.4/sitecustomize.py 1969-12-31 19:00:00.000000000 -0500
+++ foobar/lib/python2.4/sitecustomize.py 2007-09-26 15:17:05.000000000 -0400
@@ -0,0 +1,3 @@
+import sys
+
+sys.path.insert(0, '%s/lib/python2.4' % sys.prefix)
_______________________________________________
Distutils-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig