[Distutils] shebang line modified by setuptools

Phillip J. Eby pje at telecommunity.com
Mon Apr 14 00:13:14 CEST 2008


At 11:24 PM 4/13/2008 +0200, Gael Varoquaux wrote:
>Here is how things are happening (I simplified a bit the example, because
>I have a lot of things in my sys.path):
>
>varoquau at epsilon:~$ python -c "import sys; print sys.path"
>['', '/usr/local/lib/python2.5/site-packages/configobj-4.4.0-py2.5.egg',
>'/usr/lib/python2.5/site-packages', '/usr/lib/python25.zip',
>'/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
>'/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
>'/usr/local/lib/python2.5/site-packages',
>'/usr/lib/python2.5/site-packages',
>'/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode']
>varoquau at epsilon:~$ export PYTHONPATH="/home/varoquau/python:"
>varoquau at epsilon:~$ python -c "import sys; print sys.path"
>['', '/usr/local/lib/python2.5/site-packages/configobj-4.4.0-py2.5.egg',
>'/usr/lib/python2.5/site-packages', '/home/varoquau/python',
>'/home/varoquau', '/usr/lib/python25.zip', '/usr/lib/python2.5',
>'/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk',
>'/usr/lib/python2.5/lib-dynload',
>'/usr/local/lib/python2.5/site-packages',
>'/usr/lib/python2.5/site-packages',
>'/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode']
>
>Notice how what I added in my PYTHONPATH (the environment variable) is
>behind the egg. Well, what if I wanted to override configobj by my own
>version, in "/home/varoquau/python"? I am not able to do this without
>writing some Python code to monkey patch sys.path. The "$PYTHONPATH"
>should always come in front of everything. Are my explanations clear this
>time?
>
>Maybe this was not a feature, and another bug.

It's the same bug, actually.  Ideally, the configobj.egg should be in 
front of the /usr/lib/python25.zip, but not any further forward than 
that.  The last line of easy-install.pth is essentially too crude in 
its insertion method: it defaults to inserting at position zero, when 
it should default to a location that is either directly before the 
directory containing the .pth, or if that directory is the primary 
site-packages directory, then it should insert in a position that is 
after PYTHONPATH and the script directory, but before the stdlib.

Now, if someone will contribute an alternative postamble for 
easy-install.pth that can figure all that out in a 
cross-platform/cross-python-version way -- and within the constraints 
of the limited code you can jam into a .pth file -- we can get it fixed.  :)

(The cross-python-version comment is a reference to the fact that the 
'site' module was heavily rewritten in either 2.4 or 2.5; I forget 
which.  So the tools available from inside a .pth file vary somewhat 
between Python versions.)



More information about the Distutils-SIG mailing list