summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-12-12 12:33:26 -0500
committerGitHub <noreply@github.com>2016-12-12 12:33:26 -0500
commit74abcfc5431836825800550fd354f32bcc93a89d (patch)
tree96510ad5d6cfa3738c3f91371102785c2b22a835 /numpy
parent78b06bdc2f463852dd59ec8ceea79a8290a6297f (diff)
parenta98bd6bd070bb595f559727ace2f2bc9747ec7d7 (diff)
downloadnumpy-74abcfc5431836825800550fd354f32bcc93a89d.tar.gz
Merge pull request #8356 from rolk/8356_mingw_virtenv
Allow extensions to be built with MinGW in a virtualenv
Diffstat (limited to 'numpy')
-rw-r--r--numpy/distutils/mingw32ccompiler.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py
index 1e56f9dd7..3a75a70e8 100644
--- a/numpy/distutils/mingw32ccompiler.py
+++ b/numpy/distutils/mingw32ccompiler.py
@@ -253,10 +253,11 @@ def find_python_dll():
print("Looking for %s" % dllname)
# We can't do much here:
- # - find it in python main dir
+ # - find it in the virtualenv (sys.prefix)
+ # - find it in python main dir (sys.base_prefix, if in a virtualenv)
# - in system32,
# - ortherwise (Sxs), I don't know how to get it.
- lib_dirs = [sys.prefix, os.path.join(sys.prefix, 'lib')]
+ lib_dirs = [sys.prefix, sys.base_prefix, os.path.join(sys.prefix, 'lib')]
try:
lib_dirs.append(os.path.join(os.environ['SYSTEMROOT'], 'system32'))
except KeyError:
@@ -403,6 +404,12 @@ def _build_import_library_amd64():
(out_file))
return
+ # didn't exist in virtualenv, maybe in base distribution?
+ base_file = os.path.join(sys.base_prefix, 'libs', out_name)
+ if os.path.isfile(base_file):
+ log.debug('Skip building import library: "%s" exists', base_file)
+ return
+
def_name = "python%d%d.def" % tuple(sys.version_info[:2])
def_file = os.path.join(sys.prefix, 'libs', def_name)
@@ -422,12 +429,23 @@ def _build_import_library_x86():
out_name = "libpython%d%d.a" % tuple(sys.version_info[:2])
out_file = os.path.join(sys.prefix, 'libs', out_name)
if not os.path.isfile(lib_file):
- log.warn('Cannot build import library: "%s" not found' % (lib_file))
- return
+ # 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 os.path.isfile(base_lib):
+ lib_file = base_lib
+ else:
+ log.warn('Cannot build import library: "%s" not found', lib_file)
+ return
if os.path.isfile(out_file):
- log.debug('Skip building import library: "%s" exists' % (out_file))
+ log.debug('Skip building import library: "%s" exists', out_file)
+ return
+ # didn't find in virtualenv, try base distribution, too
+ base_file = os.path.join(sys.base_prefix, 'libs', out_name)
+ if os.path.isfile(base_file):
+ log.debug('Skip building import library: "%s" exists', out_file)
return
- log.info('Building import library (ARCH=x86): "%s"' % (out_file))
+ log.info('Building import library (ARCH=x86): "%s"', out_file)
from numpy.distutils import lib2def