[Distutils] Enabling local distutils.cfg usage

Tres Seaver tseaver at palladion.com
Wed Sep 26 21:47:05 CEST 2007

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.
  $ cd /tmp/virtual/
  $ bin/python -c "import distutils; print distutils.__file__"

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')::

  $ patch -p1 < ../local_distutils.patch
  patching file lib/python2.4/distutils/__init__.py
  patching file lib/python2.4/sitecustomize.py
  $ bin/python -c "import distutils; print distutils.__file__"

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

I have attached the patch I used to fix up the local environment
('local_distutils.patch' in the example above).


- --
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: local_distutils.patch
Type: text/x-patch
Size: 1007 bytes
Desc: not available
Url : http://mail.python.org/pipermail/distutils-sig/attachments/20070926/67fac2bf/attachment-0001.bin 

More information about the Distutils-SIG mailing list