[Distutils] patch: solving the two major things that people dislike about setuptools, part 1

Mark Sienkiewicz sienkiew at stsci.edu
Mon Nov 24 23:46:54 CET 2008

zooko wrote:
> Folks:
> There are two things that cause a lot of people to object to the use
> of setuptools: that it changes the semantics of PYTHONPATH, making it
> impossible to override packages on the command-line, and that it
> doesn't work when you run "setup.py install --prefix=./some_dir".

This is #1 on my list of why I hate setuptools.  I actually had it 
installed (we were wondering if we should distribute our software with 
setuptools), but I removed it when I found out that it broke PYTHONPATH.

I have a question about this patch, though:

It is somewhat awkward to apply your patch because setuptools is 
distributed and installed as a .egg file.  Rather than trying to figure 
out how to apply a patch inside a .egg file, I tried to see what the 
effect on easy_install.pth would be.  I changed my easy_install.pth file 
to look like this:

import sys; sys.__plen = len(sys.path)
import sys; print "egg insert at",sys.__egginsert
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; 
sys.path[p:p]=new; sys.__egginsert = p+len(new)

I think that this is what your patch would do, except for the debugging.

In my testing, I found that this easy_install.pth file behaves exactly 
the same as the old one.  That is because sys.__egginsert exists and is 
always 0; the value you get from looking at the environment is never 
used.  You can verify this from the print statement I included in the 
.pth file:

[banana:~] sienkiew% python
egg insert at 0
Python 2.5.1 (r251:54863, Mar 18 2008, 11:29:59)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import setuptools ; setuptools.__version__

Have I understood your patch correctly?  Do you have different behaviour 
on your system?

I think the correct behaviour is to insert the .egg file either just 
before or just after the directory where we found the .pth file.

So, instead of

we want

We can eliminate __egginsert from the code entirely.  As far as I can 
tell, the *only* purpose of __egginsert is to permit the incorrect 
behaviour that your patch is intended to fix.

Does that make sense to you?

Mark S.

More information about the Distutils-SIG mailing list