diff options
author | J. Goutin <JGoutin@users.noreply.github.com> | 2016-08-16 19:12:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-16 19:12:42 +0200 |
commit | 38d6743427f0aa31eaf2eb07df5cd11b6526d036 (patch) | |
tree | 973404cdc8abb1c8a48f0c9c515dade32202e43b /setuptools/msvc.py | |
parent | 4c2b0a2d9c19218086b5a6ecb837403bd5bb8135 (diff) | |
download | external_python_setuptools-38d6743427f0aa31eaf2eb07df5cd11b6526d036.tar.gz external_python_setuptools-38d6743427f0aa31eaf2eb07df5cd11b6526d036.tar.bz2 external_python_setuptools-38d6743427f0aa31eaf2eb07df5cd11b6526d036.zip |
Patch with numpy at execution time and not at import time
Diffstat (limited to 'setuptools/msvc.py')
-rw-r--r-- | setuptools/msvc.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/setuptools/msvc.py b/setuptools/msvc.py index bd486fa1..4646d83f 100644 --- a/setuptools/msvc.py +++ b/setuptools/msvc.py @@ -79,19 +79,17 @@ def patch_for_specialized_compiler(): pass try: - # Patch distutils._msvccompiler._get_vc_env + # Patch distutils._msvccompiler._get_vc_env for numpy compatibility unpatched['msvc14_get_vc_env'] = msvc14compiler._get_vc_env msvc14compiler._get_vc_env = msvc14_get_vc_env except NameError: pass try: - # Apply "gen_lib_options" patch from Numpy to "distutils._msvccompiler" - # to fix compatibility between "numpy.distutils" and - # "distutils._msvccompiler" (for Numpy < 1.11.2) - import numpy.distutils as np_distutils - msvc14compiler.gen_lib_options = np_distutils.ccompiler.gen_lib_options - except (ImportError, NameError): + # Patch distutils._msvccompiler.gen_lib_options + unpatched['msvc14_gen_lib_options'] = msvc14compiler.gen_lib_options + msvc14compiler.gen_lib_options = msvc14_gen_lib_options + except NameError: pass @@ -221,6 +219,19 @@ def msvc14_get_vc_env(plat_spec): 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" in distutils.ccompiler.CCompiler.spawn.__module__: + import numpy as np + return np.distutils.ccompiler.gen_lib_options(*args, **kwargs) + else: + return unpatched['msvc14_gen_lib_options'](*args, **kwargs) + + def _augment_exception(exc, version, arch=''): """ Add details to the exception message to help guide the user |