[Numpy-discussion] Setuptools leftover junk
fperez.net at gmail.com
Wed Jun 28 14:18:35 CDT 2006
On 6/28/06, David M. Cooke <cookedm at physics.mcmaster.ca> wrote:
> Done. I've also added a 'setupegg.py' module that wraps running 'setup.py'
> with an import of setuptools (it's based on the one used in matplotlib).
> easy_install still works, also.
You beat me to it :)
However, your patch has slightly different semantics from mine: if
bdist_egg fails to import, the rest of setuptools is still used. I
don't know if that's safe. My patch would consider /any/ failure in
the setuptools imports as a complete setuptools failure, and revert
out to basic distutils.
Let me know if you want me to put in my code instead, here's a patch
from my code against current svn (after your patch), in case you'd
like to try it out.
--- core.py (revision 2701)
+++ core.py (working copy)
@@ -1,20 +1,30 @@
from distutils.core import *
-if 'setuptools' in sys.modules:
- have_setuptools = True
- from setuptools import setup as old_setup
- # easy_install imports math, it may be picked up from cwd
- from setuptools.command import develop, easy_install
+# Don't pull setuptools in unless the user explicitly requests by having it
+# imported (Andrew's trick).
+have_setuptools = 'setuptools' in sys.modules
+# Even if setuptools is in, do a few things carefully to make sure the version
+# is recent enough to have everything we need before assuming we can proceed
+# using setuptools throughout
- # very old versions of setuptools don't have this
+ from setuptools import setup as old_setup
+ # very old setuptools don't have this
from setuptools.command import bdist_egg
+ # easy_install imports math, it may be picked up from cwd
+ from setuptools.command import develop, easy_install
+ # Any failure here is probably due to an old or broken setuptools
+ # leftover in sys.modules, so treat it as if it simply weren't
+ # available.
have_setuptools = False
+# If setuptools was flagged as unavailable due to import problems, we need the
+# basic distutils support
+if not have_setuptools:
from distutils.core import setup as old_setup
- have_setuptools = False
from numpy.distutils.extension import Extension
from numpy.distutils.command import config
More information about the Numpy-discussion