summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-06-27 07:42:28 -0600
committerGitHub <noreply@github.com>2017-06-27 07:42:28 -0600
commitbf12213a1835d42acbfc0bd5f5587d30372fc50e (patch)
treecf017928c279b29189995eb2f3e3120b8da3f9f3 /numpy
parente9e3a3b387fd870b72e92e09ca5341e6bf306d4d (diff)
parenta2b416f60e6f3f2746bf3edaf8e6161204f528a5 (diff)
downloadnumpy-bf12213a1835d42acbfc0bd5f5587d30372fc50e.tar.gz
Merge pull request #9280 from rolk/9280_msys2_basepref
BUG: Make extensions compilable with MinGW on Py2.7
Diffstat (limited to 'numpy')
-rw-r--r--numpy/distutils/mingw32ccompiler.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py
index 870df0693..ec672e205 100644
--- a/numpy/distutils/mingw32ccompiler.py
+++ b/numpy/distutils/mingw32ccompiler.py
@@ -251,11 +251,14 @@ def find_python_dll():
# We can't do much here:
# - find it in the virtualenv (sys.prefix)
# - find it in python main dir (sys.base_prefix, if in a virtualenv)
+ # - sys.real_prefix is main dir for virtualenvs in Python 2.7
# - 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)
+ elif hasattr(sys, 'real_prefix') and sys.real_prefix != sys.prefix:
+ stems.append(sys.real_prefix)
sub_dirs = ['', 'lib', 'bin']
# generate possible combinations of directory trees and sub-directories
@@ -426,8 +429,10 @@ 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)
+ elif hasattr(sys, 'real_prefix') and sys.real_prefix != sys.prefix:
+ stems.append(sys.real_prefix)
# possible subdirectories within those trees where it is placed
sub_dirs = ['libs', 'lib']
@@ -481,8 +486,15 @@ def _build_import_library_x86():
lib_file = os.path.join(sys.prefix, 'libs', lib_name)
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)
+ # and use that instead if found there. for Python 2.7 venvs, the base
+ # directory is in attribute real_prefix instead of base_prefix.
+ if hasattr(sys, 'base_prefix'):
+ base_lib = os.path.join(sys.base_prefix, 'libs', lib_name)
+ elif hasattr(sys, 'real_prefix'):
+ base_lib = os.path.join(sys.real_prefix, 'libs', lib_name)
+ else:
+ base_lib = '' # os.path.isfile('') == False
+
if os.path.isfile(base_lib):
lib_file = base_lib
else: