|
|
b6358a |
diff --git a/doc/source/tutorial/weave.rst b/doc/source/tutorial/weave.rst
|
|
|
b6358a |
index 12cff19..7a481db 100644
|
|
|
b6358a |
--- a/doc/source/tutorial/weave.rst
|
|
|
b6358a |
+++ b/doc/source/tutorial/weave.rst
|
|
|
b6358a |
@@ -885,11 +885,11 @@ Microsoft VC++ installed.
|
|
|
b6358a |
When ``inline`` is first run, you'll notice that pause and some trash printed
|
|
|
b6358a |
to the screen. The "trash" is acutually part of the compilers output that
|
|
|
b6358a |
distutils does not supress. The name of the extension file,
|
|
|
b6358a |
-``sc_bighonkingnumber.cpp``, is generated from the md5 check sum of the C/C++
|
|
|
b6358a |
-code fragment. On Unix or windows machines with only gcc installed, the trash
|
|
|
b6358a |
-will not appear. On the second call, the code fragment is not compiled since
|
|
|
b6358a |
-it already exists, and only the answer is returned. Now kill the interpreter
|
|
|
b6358a |
-and restart, and run the same code with a different string.
|
|
|
b6358a |
+``sc_bighonkingnumber.cpp``, is generated from the SHA-256 check sum of the
|
|
|
b6358a |
+C/C++ code fragment. On Unix or windows machines with only gcc installed, the
|
|
|
b6358a |
+trash will not appear. On the second call, the code fragment is not compiled
|
|
|
b6358a |
+since it already exists, and only the answer is returned. Now kill the
|
|
|
b6358a |
+interpreter and restart, and run the same code with a different string.
|
|
|
b6358a |
|
|
|
b6358a |
::
|
|
|
b6358a |
|
|
|
b6358a |
@@ -1151,8 +1151,8 @@ A quick look at the code
|
|
|
b6358a |
------------------------
|
|
|
b6358a |
|
|
|
b6358a |
``weave`` generates a C++ file holding an extension function for each
|
|
|
b6358a |
-``inline`` code snippet. These file names are generated using from the md5
|
|
|
b6358a |
-signature of the code snippet and saved to a location specified by the
|
|
|
b6358a |
+``inline`` code snippet. These file names are generated using from the
|
|
|
b6358a |
+SHA-256 signature of the code snippet and saved to a location specified by the
|
|
|
b6358a |
PYTHONCOMPILED environment variable (discussed later). The cpp files are
|
|
|
b6358a |
generally about 200-400 lines long and include quite a few functions to
|
|
|
b6358a |
support type conversions, etc. However, the actual compiled function is
|
|
|
b6358a |
@@ -2401,10 +2401,10 @@ been built before.
|
|
|
b6358a |
|
|
|
b6358a |
.. note::
|
|
|
b6358a |
If we were willing to always pay the penalty of building the C++
|
|
|
b6358a |
- code for a module, we could store the md5 checksum of the C++ code
|
|
|
b6358a |
+ code for a module, we could store the SHA-256 checksum of the C++ code
|
|
|
b6358a |
along with some information about the compiler, platform, etc. Then,
|
|
|
b6358a |
``ext_module.compile()`` could try importing the module before it
|
|
|
b6358a |
- actually compiles it, check the md5 checksum and other meta-data in
|
|
|
b6358a |
+ actually compiles it, check the SHA-256 checksum and other meta-data in
|
|
|
b6358a |
the imported module with the meta-data of the code it just produced
|
|
|
b6358a |
and only compile the code if the module didn't exist or the
|
|
|
b6358a |
meta-data didn't match. This would reduce the above code to::
|
|
|
b6358a |
diff --git a/scipy/weave/accelerate_tools.py b/scipy/weave/accelerate_tools.py
|
|
|
b6358a |
index 935ca23..1627447 100644
|
|
|
b6358a |
--- a/scipy/weave/accelerate_tools.py
|
|
|
b6358a |
+++ b/scipy/weave/accelerate_tools.py
|
|
|
b6358a |
@@ -12,7 +12,7 @@ from __future__ import absolute_import, print_function
|
|
|
b6358a |
|
|
|
b6358a |
from types import InstanceType, XRangeType
|
|
|
b6358a |
import inspect
|
|
|
b6358a |
-import scipy.weave.md5_load as md5
|
|
|
b6358a |
+from hashlib import sha256
|
|
|
b6358a |
import scipy.weave as weave
|
|
|
b6358a |
from numpy.testing import assert_
|
|
|
b6358a |
|
|
|
b6358a |
@@ -342,7 +342,7 @@ class accelerate(object):
|
|
|
b6358a |
return fast
|
|
|
b6358a |
|
|
|
b6358a |
def identifier(self,signature):
|
|
|
b6358a |
- # Build an MD5 checksum
|
|
|
b6358a |
+ # Build a SHA-256 checksum
|
|
|
b6358a |
f = self.function
|
|
|
b6358a |
co = f.func_code
|
|
|
b6358a |
identifier = str(signature)+\
|
|
|
b6358a |
@@ -350,7 +350,7 @@ class accelerate(object):
|
|
|
b6358a |
str(co.co_consts)+\
|
|
|
b6358a |
str(co.co_varnames)+\
|
|
|
b6358a |
co.co_code
|
|
|
b6358a |
- return 'F'+md5.md5(identifier).hexdigest()
|
|
|
b6358a |
+ return 'F' + sha256(identifier).hexdigest()
|
|
|
b6358a |
|
|
|
b6358a |
def accelerate(self,signature,identifier):
|
|
|
b6358a |
P = Python2CXX(self.function,signature,name=identifier)
|
|
|
b6358a |
diff --git a/scipy/weave/build_tools.py b/scipy/weave/build_tools.py
|
|
|
b6358a |
index c0f8baa..27d27a4 100644
|
|
|
b6358a |
--- a/scipy/weave/build_tools.py
|
|
|
b6358a |
+++ b/scipy/weave/build_tools.py
|
|
|
b6358a |
@@ -234,7 +234,7 @@ def build_extension(module_path,compiler_name = '',build_dir = None,
|
|
|
b6358a |
# dag. We keep having to add directories to the path to keep
|
|
|
b6358a |
# object files separated from each other. gcc2.x and gcc3.x C++
|
|
|
b6358a |
# object files are not compatible, so we'll stick them in a sub
|
|
|
b6358a |
- # dir based on their version. This will add an md5 check sum
|
|
|
b6358a |
+ # dir based on their version. This will add a SHA-256 check sum
|
|
|
b6358a |
# of the compiler binary to the directory name to keep objects
|
|
|
b6358a |
# from different compilers in different locations.
|
|
|
b6358a |
|
|
|
b6358a |
diff --git a/scipy/weave/catalog.py b/scipy/weave/catalog.py
|
|
|
b6358a |
index 274ed41..bb15f26 100644
|
|
|
b6358a |
--- a/scipy/weave/catalog.py
|
|
|
b6358a |
+++ b/scipy/weave/catalog.py
|
|
|
b6358a |
@@ -84,13 +84,13 @@ def getmodule(object):
|
|
|
b6358a |
def expr_to_filename(expr):
|
|
|
b6358a |
""" Convert an arbitrary expr string to a valid file name.
|
|
|
b6358a |
|
|
|
b6358a |
- The name is based on the md5 check sum for the string and
|
|
|
b6358a |
+ The name is based on the SHA-256 check sum for the string and
|
|
|
b6358a |
Something that was a little more human readable would be
|
|
|
b6358a |
nice, but the computer doesn't seem to care.
|
|
|
b6358a |
"""
|
|
|
b6358a |
- import scipy.weave.md5_load as md5
|
|
|
b6358a |
+ from hashlib import sha256
|
|
|
b6358a |
base = 'sc_'
|
|
|
b6358a |
- return base + md5.new(expr).hexdigest()
|
|
|
b6358a |
+ return base + sha256(expr).hexdigest()
|
|
|
b6358a |
|
|
|
b6358a |
def unique_file(d,expr):
|
|
|
b6358a |
""" Generate a unqiue file name based on expr in directory d
|
|
|
b6358a |
diff --git a/scipy/weave/md5_load.py b/scipy/weave/md5_load.py
|
|
|
b6358a |
deleted file mode 100644
|
|
|
b6358a |
index 80594ad..0000000
|
|
|
b6358a |
--- a/scipy/weave/md5_load.py
|
|
|
b6358a |
+++ /dev/null
|
|
|
b6358a |
@@ -1,11 +0,0 @@
|
|
|
b6358a |
-# Import correct md5, irrespective of the Python version
|
|
|
b6358a |
-#
|
|
|
b6358a |
-# `hashlib` was introduced in 2.5, deprecating `md5`
|
|
|
b6358a |
-from __future__ import absolute_import, print_function
|
|
|
b6358a |
-
|
|
|
b6358a |
-try:
|
|
|
b6358a |
- from hashlib import *
|
|
|
b6358a |
-except ImportError:
|
|
|
b6358a |
- from md5 import *
|
|
|
b6358a |
-
|
|
|
b6358a |
-new = md5
|
|
|
b6358a |
diff --git a/scipy/weave/platform_info.py b/scipy/weave/platform_info.py
|
|
|
b6358a |
index df67ca5..f7d7490 100644
|
|
|
b6358a |
--- a/scipy/weave/platform_info.py
|
|
|
b6358a |
+++ b/scipy/weave/platform_info.py
|
|
|
b6358a |
@@ -89,13 +89,13 @@ def compiler_exe_path(exe_name):
|
|
|
b6358a |
return exe_path
|
|
|
b6358a |
|
|
|
b6358a |
def check_sum(file):
|
|
|
b6358a |
- import scipy.weave.md5_load as md5
|
|
|
b6358a |
+ from hashlib import sha256
|
|
|
b6358a |
try:
|
|
|
b6358a |
f = open(file,'r')
|
|
|
b6358a |
bytes = f.read(-1)
|
|
|
b6358a |
except IOError:
|
|
|
b6358a |
bytes = ''
|
|
|
b6358a |
- chk_sum = md5.md5(bytes)
|
|
|
b6358a |
+ chk_sum = sha256(bytes)
|
|
|
b6358a |
return chk_sum.hexdigest()
|
|
|
b6358a |
|
|
|
b6358a |
def get_compiler_dir(compiler_name):
|