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

zooko zooko at zooko.com
Sat Nov 15 20:42:05 CET 2008


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 patch addresses the first one. Currently, if you ever allow
setuptools to write into your system directory
(e.g. /usr/lib/python2.5/site-packages) then it will install a .pth
file which changes the behavior of PYTHONPATH.

This will prevent you from over-riding the installed package with a
specific package on the command-line, such as:

PYTHONPATH=./that-version-of-Twisted/ python ./my_script.py

Many people find this behavior of setuptools objectionable [1, 2, 3,
plus personal correspondance when I did my "Why do you hate
setuptools?" survey].  Fortunately it seems possible to preserve the
precedence of PYTHONPATH modules while still having installed eggs
override installed non-eggs, as motivated in [4].

Sat Nov 15 11:59:32 MST 2008  zooko at zooko.com
   * leave the PYTHONPATH dirs at the front of the sys.path
   This is in accordance with
   http://www.python.org/doc/2.5.2/inst/search-path.html , which says
   "The PYTHONPATH variable can be set to a list of paths that will be
   added to the beginning of sys.path.", and it resolves an objection
   many people have which impels them to ban setuptools from systems
   they administrate.
--- old-dw-0.6c9/setuptools/command/easy_install.py
+++ new-dw-0.6c9/setuptools/command/easy_install.py
@@ -1364,7 +1364,7 @@
                  "%s\n"
                  "import sys; new=sys.path[sys.__plen:];"
                  " del sys.path[sys.__plen:];"
-                " p=getattr(sys,'__egginsert',0); sys.path[p:p]=new;"
+                " p=getattr(sys,'__egginsert',len(os.environ.get 
('PYTHONPATH','').split(os.pathsep))); sys.path[p:p]=new;"
                  " sys.__egginsert = p+len(new)\n"
              ) % data



Regards,

Zooko
---
http://allmydata.org -- Tahoe, the Least-Authority Filesystem
http://allmydata.com -- back up all your files for $10/month

[1] http://mail.python.org/pipermail/distutils-sig/2006-July/006492.html
[2] https://www.dfwpython.org/pipermail/dfwpython/2007-June/000756.html
[3] http://www.rittau.org/blog/20070726-02
[4] http://mail.python.org/pipermail/python-dev/2008-March/077918.html

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20081115/b178be45/attachment.txt>


More information about the Distutils-SIG mailing list