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

Phillip J. Eby pje at telecommunity.com
Tue Nov 25 20:39:48 CET 2008

At 10:56 AM 11/25/2008 -0500, Mark Sienkiewicz wrote:

> >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
> >p=getattr(sys,'__egginsert',len(os.environ.get('PYTHONPATH','').spl 
> it(os.pathsep)));
> >
> >we want
> >p=sys.path.index(sitedir);
> >
>Does this meet your criterion without breaking anything else?

The principle is correct; I'm not sure the implementation is.  For 
case-insensitive filesystems, sitedir may or may not be normalized, 
and sys.path probably isn't.  But yes, that's the general idea.

The only reason I didn't take that approach myself is because my head 
hurt trying to come up with a provably-correct way to implement this 
policy.  ;-)

>IMHO, this is actually not a great patch because it depends on 
>knowledge that should be private to distutils, but setuptools is 
>already violating that information hiding.  (For example, it assumes 
>that it is safe to alter sys.path while distutils is loading the 
>.pth file; I didn't see that documented anywhere, but we can see 
>that it works.)
>b.t.w. You could make easy_install.pth read:
>    import setuptools; setuptools.prep_sys_path()
>    module-name.egg
>    import setuptools; setuptools.alter_sys_path()
>and then patches to the first/last line would be easier -- they 
>would just happen when you install a new setuptools.

It would have to be a separate module, added just for this 
purpose...  and of course it would introduce a runtime dependency 
that would otherwise be unnecessary.

More information about the Distutils-SIG mailing list