summaryrefslogtreecommitdiff
path: root/numpy/distutils/mingw32ccompiler.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/distutils/mingw32ccompiler.py')
-rw-r--r--numpy/distutils/mingw32ccompiler.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py
index 4681d403b..82d296434 100644
--- a/numpy/distutils/mingw32ccompiler.py
+++ b/numpy/distutils/mingw32ccompiler.py
@@ -547,12 +547,12 @@ if sys.platform == 'win32':
# Value from msvcrt.CRT_ASSEMBLY_VERSION under Python 3.3.0
# on Windows XP:
_MSVCRVER_TO_FULLVER['100'] = "10.0.30319.460"
- # Python 3.7 uses 1415, but get_build_version returns 140 ??
- _MSVCRVER_TO_FULLVER['140'] = "14.15.26726.0"
- if hasattr(msvcrt, "CRT_ASSEMBLY_VERSION"):
- major, minor, rest = msvcrt.CRT_ASSEMBLY_VERSION.split(".", 2)
- _MSVCRVER_TO_FULLVER[major + minor] = msvcrt.CRT_ASSEMBLY_VERSION
- del major, minor, rest
+ crt_ver = getattr(msvcrt, 'CRT_ASSEMBLY_VERSION', None)
+ if crt_ver is not None: # Available at least back to Python 3.3
+ maj, min = re.match(r'(\d+)\.(\d)', crt_ver).groups()
+ _MSVCRVER_TO_FULLVER[maj + min] = crt_ver
+ del maj, min
+ del crt_ver
except ImportError:
# If we are here, means python was not built with MSVC. Not sure what
# to do in that case: manifest building will fail, but it should not be
@@ -647,11 +647,9 @@ def generate_manifest(config):
if msver is not None:
if msver >= 8:
check_embedded_msvcr_match_linked(msver)
- ma = int(msver)
- mi = int((msver - ma) * 10)
+ ma_str, mi_str = str(msver).split('.')
# Write the manifest file
- manxml = msvc_manifest_xml(ma, mi)
- man = open(manifest_name(config), "w")
- config.temp_files.append(manifest_name(config))
- man.write(manxml)
- man.close()
+ manxml = msvc_manifest_xml(int(ma_str), int(mi_str))
+ with open(manifest_name(config), "w") as man:
+ config.temp_files.append(manifest_name(config))
+ man.write(manxml)