Commit 5c940cc9 authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #739 from JGoutin/patch-1

numpy.distutils and distutils._msvccompiler compatibility
parents ac10f58a 8d1eecae
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
CHANGES CHANGES
======= =======
v25.3.1
-------
* #739 Fix unquoted libpaths by fixing compatibility between `numpy.distutils` and `distutils._msvccompiler` for numpy < 1.11.2 (Fix issue #728, error also fixed in Numpy).
v25.3.0 v25.3.0
------- -------
...@@ -16,20 +21,21 @@ v25.2.0 ...@@ -16,20 +21,21 @@ v25.2.0
v25.1.6 v25.1.6
------- -------
* #725 * #725: revert `library_dir_option` patch (Error is related to `numpy.distutils` and make errors on non Numpy users).
v25.1.5 v25.1.5
------- -------
* #720 * #720
* #723 * #723: Improve patch for `library_dir_option`.
v25.1.4 v25.1.4
------- -------
* #717 * #717
* #713 * #713
* #707 via #715 * #707: Fix Python 2 compatibility for MSVC by catching errors properly.
* #715: Fix unquoted libpaths by patching `library_dir_option`.
v25.1.3 v25.1.3
------- -------
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
This module adds improved support for Microsoft Visual C++ compilers. This module adds improved support for Microsoft Visual C++ compilers.
""" """
import os import os
import sys
import platform import platform
import itertools import itertools
import distutils.errors import distutils.errors
from distutils.version import StrictVersion
from setuptools.extern.six.moves import filterfalse from setuptools.extern.six.moves import filterfalse
...@@ -75,14 +77,21 @@ def patch_for_specialized_compiler(): ...@@ -75,14 +77,21 @@ def patch_for_specialized_compiler():
msvc9compiler.find_vcvarsall = msvc9_find_vcvarsall msvc9compiler.find_vcvarsall = msvc9_find_vcvarsall
unpatched['msvc9_query_vcvarsall'] = msvc9compiler.query_vcvarsall unpatched['msvc9_query_vcvarsall'] = msvc9compiler.query_vcvarsall
msvc9compiler.query_vcvarsall = msvc9_query_vcvarsall msvc9compiler.query_vcvarsall = msvc9_query_vcvarsall
except Exception: except NameError:
pass pass
try: try:
# Patch distutils._msvccompiler._get_vc_env # Patch distutils._msvccompiler._get_vc_env
unpatched['msvc14_get_vc_env'] = msvc14compiler._get_vc_env unpatched['msvc14_get_vc_env'] = msvc14compiler._get_vc_env
msvc14compiler._get_vc_env = msvc14_get_vc_env msvc14compiler._get_vc_env = msvc14_get_vc_env
except Exception: except NameError:
pass
try:
# Patch distutils._msvccompiler.gen_lib_options for Numpy
unpatched['msvc14_gen_lib_options'] = msvc14compiler.gen_lib_options
msvc14compiler.gen_lib_options = msvc14_gen_lib_options
except NameError:
pass pass
...@@ -212,6 +221,19 @@ def msvc14_get_vc_env(plat_spec): ...@@ -212,6 +221,19 @@ def msvc14_get_vc_env(plat_spec):
raise raise
def msvc14_gen_lib_options(*args, **kwargs):
"""
Patched "distutils._msvccompiler.gen_lib_options" for fix
compatibility between "numpy.distutils" and "distutils._msvccompiler"
(for Numpy < 1.11.2)
"""
if "numpy.distutils" in sys.modules:
import numpy as np
if StrictVersion(np.__version__) < StrictVersion('1.11.2'):
return np.distutils.ccompiler.gen_lib_options(*args, **kwargs)
return unpatched['msvc14_gen_lib_options'](*args, **kwargs)
def _augment_exception(exc, version, arch=''): def _augment_exception(exc, version, arch=''):
""" """
Add details to the exception message to help guide the user Add details to the exception message to help guide the user
...@@ -243,7 +265,8 @@ def _augment_exception(exc, version, arch=''): ...@@ -243,7 +265,8 @@ def _augment_exception(exc, version, arch=''):
elif version >= 14.0: elif version >= 14.0:
# For VC++ 14.0 Redirect user to Visual C++ Build Tools # For VC++ 14.0 Redirect user to Visual C++ Build Tools
message += (' Get it with "Microsoft Visual C++ Build Tools": ' message += (' Get it with "Microsoft Visual C++ Build Tools": '
r'http://landinghub.visualstudio.com/visual-cpp-build-tools') r'http://landinghub.visualstudio.com/'
'visual-cpp-build-tools')
exc.args = (message, ) exc.args = (message, )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment