summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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