diff --git a/scipy/weave/accelerate_tools.py b/scipy/weave/accelerate_tools.py index bc529565ac4f..7079a42155b9 100644 --- a/scipy/weave/accelerate_tools.py +++ b/scipy/weave/accelerate_tools.py @@ -364,7 +364,7 @@ def singleton(self,signature): return fast def identifier(self,signature): - # Build a SHA-256 checksum + # Build a (truncated, see gh-3216) SHA-256 checksum f = self.function co = f.func_code identifier = str(signature) + \ @@ -372,7 +372,7 @@ def identifier(self,signature): str(co.co_consts) + \ str(co.co_varnames) + \ co.co_code - return 'F' + sha256(identifier).hexdigest() + return 'F' + sha256(identifier).hexdigest()[:96] def accelerate(self,signature,identifier): P = Python2CXX(self.function,signature,name=identifier) diff --git a/scipy/weave/build_tools.py b/scipy/weave/build_tools.py index 301acff43c8e..04d5dc2733d8 100644 --- a/scipy/weave/build_tools.py +++ b/scipy/weave/build_tools.py @@ -236,8 +236,8 @@ def build_extension(module_path,compiler_name='',build_dir=None, # object files separated from each other. gcc2.x and gcc3.x C++ # object files are not compatible, so we'll stick them in a sub # dir based on their version. This will add a SHA-256 check sum - # of the compiler binary to the directory name to keep objects - # from different compilers in different locations. + # (truncated to ~100 characters) of the compiler binary to the directory + # name to keep objects from different compilers in different locations. compiler_dir = platform_info.get_compiler_dir(compiler_name) temp_dir = os.path.join(temp_dir,compiler_dir) diff --git a/scipy/weave/catalog.py b/scipy/weave/catalog.py index 2f50e1377f8b..ce546d95ed2a 100644 --- a/scipy/weave/catalog.py +++ b/scipy/weave/catalog.py @@ -92,7 +92,9 @@ def expr_to_filename(expr): """ from hashlib import sha256 base = 'sc_' - return base + sha256(expr).hexdigest() + # 99 chars is enough for unique filenames; too long names don't work for + # MSVC (see gh-3216). Don't use md5, gives a FIPS warning. + return base + sha256(expr).hexdigest()[:96] def unique_file(d,expr): diff --git a/scipy/weave/platform_info.py b/scipy/weave/platform_info.py index c11bb58fd22b..ad8a1a105a48 100644 --- a/scipy/weave/platform_info.py +++ b/scipy/weave/platform_info.py @@ -103,7 +103,7 @@ def check_sum(file): except IOError: bytes = '' chk_sum = sha256(bytes) - return chk_sum.hexdigest() + return chk_sum.hexdigest()[:96] # truncation needed, see gh-3216 def get_compiler_dir(compiler_name):