[Distutils] Enabling local distutils.cfg usage

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


-----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          tseaver at palladion.com
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-----
-------------- 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