summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Perez <fperez@fperez.org>2007-12-30 03:04:17 +0000
committerFernando Perez <fperez@fperez.org>2007-12-30 03:04:17 +0000
commit083ca64099268bc5967d25a15f9a4d26d750eb69 (patch)
treef30d625ff545b721477e77bcf5c03246f38511fe
parentb4a25a4ae23890d04b993698a7e82f769ee748a5 (diff)
downloadnumpy-083ca64099268bc5967d25a15f9a4d26d750eb69.tar.gz
Modify the setup routine to indicate that it is being run via a system
global. This allows the main __init__ to detect the setup and avoid attempting to load things that aren't built yet. This is hackish, but the previously used method would fail if there was an existing system-wide numpy already installed, for example (which users might have no control over). There were frequent reports of problems with the previous method: - http://projects.scipy.org/pipermail/scipy-user/2007-November/014511.html - Tickets #561 and #565
-rw-r--r--numpy/__init__.py12
-rwxr-xr-xsetup.py7
2 files changed, 15 insertions, 4 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py
index dbba4f88d..f07d862a5 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -16,16 +16,20 @@ Documentation is available in the docstrings and at
http://www.scipy.org.
"""
+# We first need to detect if we're being called as part of the numpy setup
+# procedure itself in a reliable manner.
try:
- from numpy.__config__ import show as show_config
-except ImportError:
- show_config = None
+ __NUMPY_SETUP__
+except NameError:
+ __NUMPY_SETUP__ = False
+
-if show_config is None:
+if __NUMPY_SETUP__:
import sys as _sys
print >> _sys.stderr, 'Running from numpy source directory.'
del _sys
else:
+ from numpy.__config__ import show as show_config
from version import version as __version__
from _import_tools import PackageLoader
diff --git a/setup.py b/setup.py
index d98fece35..b9acb647b 100755
--- a/setup.py
+++ b/setup.py
@@ -15,6 +15,7 @@ basic linear algebra and random number generation.
DOCLINES = __doc__.split("\n")
+import __builtin__
import os
import sys
@@ -37,6 +38,12 @@ Operating System :: MacOS
# update it when the contents of directories change.
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
+# This is a bit hackish: we are setting a global variable so that the main
+# numpy __init__ can detect if it is being loaded by the setup routine, to
+# avoid attempting to load components that aren't built yet. While ugly, it's
+# a lot more robust than what was previously being used.
+__builtin__.__NUMPY_SETUP__ = True
+
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration