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

zooko zooko at zooko.com
Sat Nov 15 20:59:25 CET 2008


There are two things that cause a lot of people to object to the use
of setuptools: that it changes the semantics of PYTHONPATH, and that it
doesn't work when you run "setup.py install --prefix=somedir".

This pair of patches addresses the second issue: that when you run
"python ./setup.py install --prefix=somedir" it doesn't work like
distutils does.  It is possible to work-around this in various ways
(either with --svem --record or with mkdir -p and PYTHONPATH before
invoking setup.py) but the existence of these work-arounds does not
seem to be sufficient to make some people accept the use of setuptools
[1, 2, personal correspondance from my "Why do you hate setuptools?"

These patches make setuptools behave more like distutils in this

I know that you had good reason to do these sanity checks in the first
place, PJE, but I hope that you will consider accepting these patches
in order to extend setuptools's reach.

Sat Nov 15 12:04:20 MST 2008  zooko at zooko.com
   * try to mkdir the install directory
   This eases the common use case of "./setup.py install -- 
   and makes setuptools behave more like distutils in this case.
--- old-dw-0.6c9/setuptools/command/easy_install.py
+++ new-dw-0.6c9/setuptools/command/easy_install.py
@@ -249,6 +249,14 @@
          instdir = normalize_path(self.install_dir)
          pth_file = os.path.join(instdir,'easy-install.pth')

+        # mkdir it if necessary
+        try:
+            os.makedirs(instdir)
+        except OSError:
+            # Oh well -- hopefully this error simply means that it  
is already there.
+            # If not the subsequent write test will identify the  
+            pass
          # Is it a configured, PYTHONPATH, implicit, or explicit  
site dir?
          is_site_dir = instdir in self.all_site_dirs

Sat Nov 15 12:05:01 MST 2008  zooko at zooko.com
   * change exception into warning when target install dir isn't pth- 
   This eases the common use case of "./setup.py install --prefix=foo"
   followed by some other mechanism to make sure that ./foo/... is
   importable, and makes setuptools behave more like distutils in  
this regard.

--- old-dw-0.6c9/setuptools/command/easy_install.py
+++ new-dw-0.6c9/setuptools/command/easy_install.py
@@ -276,7 +276,7 @@

          if not is_site_dir and not self.multi_version:
              # Can't install non-multi to non-site dir
-            raise DistutilsError(self.no_default_version_msg())
+            log.warn(self.no_default_version_msg())

          if is_site_dir:
              if self.pth_file is None:
@@ -1059,7 +1059,9 @@


-Please make the appropriate changes for your system and try  
again.""" % (
+Proceeding to install.  Please remember that unless you make one of
+these changes you will not be able to run the installed code.
+""" % (
          self.install_dir, os.environ.get('PYTHONPATH','')


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

[1] http://adam.gomaa.us/blog/easy-install-isnt/
[2] https://bugs.launchpad.net/pyopenssl/+bug/238658/comments/25

More information about the Distutils-SIG mailing list