summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorRoland Kaufmann <rka081+numpy@uib.no>2017-06-21 11:37:00 +0200
committerRoland Kaufmann <rka081+numpy@uib.no>2017-06-22 23:23:35 +0200
commit6c9dece14f90d972ca83ae0cfb879c3f74a7bf1f (patch)
tree072b96515a0969b0ef90becabffab5863c332cc9 /numpy
parentcfb909f35de8ad238066eb176bc408d86f15c9c8 (diff)
downloadnumpy-6c9dece14f90d972ca83ae0cfb879c3f74a7bf1f.tar.gz
BUG: Make extensions compilable with MinGW on Py2.7
The original changeset 1c8ecc7 to make extensions compilable with MinGW used the base_prefix attribute unconditionally. However, this is not available in versions before Python 3.3. This changeset introduces a check for whether the attribute is available so that the code will work without errors also on Python 2.7. However, this may lead to surprising results when compiling in a virtualenv. Hat tip to Diorcet Yann (@diorcety) for pointing out this problem.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/distutils/mingw32ccompiler.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py
index 870df0693..8e14fea13 100644
--- a/numpy/distutils/mingw32ccompiler.py
+++ b/numpy/distutils/mingw32ccompiler.py
@@ -254,7 +254,7 @@ def find_python_dll():
# - in system32,
# - ortherwise (Sxs), I don't know how to get it.
stems = [sys.prefix]
- if sys.base_prefix != sys.prefix:
+ if hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix:
stems.append(sys.base_prefix)
sub_dirs = ['', 'lib', 'bin']
@@ -426,7 +426,7 @@ def _check_for_import_lib():
# directory trees that may contain the library
stems = [sys.prefix]
- if sys.base_prefix != sys.prefix:
+ if hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix:
stems.append(sys.base_prefix)
# possible subdirectories within those trees where it is placed
@@ -482,7 +482,11 @@ def _build_import_library_x86():
if not os.path.isfile(lib_file):
# didn't find library file in virtualenv, try base distribution, too,
# and use that instead if found there
- base_lib = os.path.join(sys.base_prefix, 'libs', lib_name)
+ if hasattr(sys, 'base_prefix'):
+ base_lib = os.path.join(sys.base_prefix, 'libs', lib_name)
+ else:
+ base_lib = '' # os.path.isfile('') == False
+
if os.path.isfile(base_lib):
lib_file = base_lib
else: