[Distutils] shebang line modified by setuptools

Gael Varoquaux gael.varoquaux at normalesup.org
Sun Apr 13 23:24:20 CEST 2008


On Sun, Apr 13, 2008 at 05:12:48PM -0400, Phillip J. Eby wrote:
> However, now that it's a known bug, it's merely an engineering problem to 
> fix it.  :)

Fantastic! I thought it was a feature, so I was unhappy, but if it's only
a bug, well, I know too well that these things happen, and if nobody
reports them, they don't get fixed.


>> With standard Python, I can override the import mechanism using the
>> PYTHONPATH. This way I can make sure that the modules I want get
>> imported. And pretty much all the programs I can think of with a path
>> environment variable behave like this. Now if I have a module installed
>> with setuptools, I no longer have the possibility to do this, because
>> setuptools inserts it self before the PYTHONPATH.
>
> I'm not following you here.  Are you trying to specify the use of a 
> different version of setuptools?  What do you mean by "setuptools inserts 
> itself before the PYTHONPATH"?

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. In which case, please
excuse the tone of my previous message. I should have reported the
problem. I thought it was a know one, because it seems so natural to do
the following in a Unix world.

Cheers,

Gaël


More information about the Distutils-SIG mailing list