diff options
author | David Cournapeau <cournape@gmail.com> | 2008-12-26 12:36:19 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2008-12-26 12:36:19 +0000 |
commit | a97ea4a100990a09b301aac755f6e4d19340642e (patch) | |
tree | 7ecf1eef87ede1982ad4f6a3bb6700aed8393a68 /numpy | |
parent | 3f82799ae312c903bb6136684214533b5e4673af (diff) | |
download | numpy-a97ea4a100990a09b301aac755f6e4d19340642e.tar.gz |
Do not import msvcrt globally in mingw32compiler module, since the module is imported on all platforms.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/distutils/mingw32ccompiler.py | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py index d4f2a19cd..738f4ba00 100644 --- a/numpy/distutils/mingw32ccompiler.py +++ b/numpy/distutils/mingw32ccompiler.py @@ -241,26 +241,31 @@ def build_import_library(): # directory, but this requires the manifest for this to work. This is a big # mess, thanks MS for a wonderful system. -# XXX: ideally, we should use exactly the same version as used by python, but I -# have no idea how to obtain the exact version from python. We could use the -# strings utility on python.exe, maybe ? -try: - import msvcrt - if hasattr(msvcrt, "CRT_ASSEMBLY_VERSION"): - _MSVCRVER_TO_FULLVER = {'90': msvcrt.CRT_ASSEMBLY_VERSION} - else: - _MSVCRVER_TO_FULLVER = {'90': "9.0.21022.8"} -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 used in - # that case anyway - log.warn('Cannot import msvcrt: using manifest will not be possible') +# XXX: ideally, we should use exactly the same version as used by python. I +# submitted a patch to get this version, but it was only included for python +# 2.6.1 and above. So for versions below, we use a "best guess". +_MSVCRVER_TO_FULLVER = {'90': None} + +def msvcrt_version(num): + k = _MSVCRVER_TO_FULLVER[num] + if not k: + try: + import msvcrt + if hasattr(msvcrt, "CRT_ASSEMBLY_VERSION"): + _MSVCRVER_TO_FULLVER = {'90': msvcrt.CRT_ASSEMBLY_VERSION} + else: + _MSVCRVER_TO_FULLVER = {'90': "9.0.21022.8"} + 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 used in + # that case anyway + log.warn('Cannot import msvcrt: using manifest will not be possible') def msvc_manifest_xml(maj, min): """Given a major and minor version of the MSVCR, returns the corresponding XML file.""" try: - fullver = _MSVCRVER_TO_FULLVER[str(maj * 10 + min)] + fullver = msvcrt_version[str(maj * 10 + min)] except KeyError: raise ValueError("Version %d,%d of MSVCRT not supported yet" \ % (maj, min)) |