1 |
On 10/20/2017 12:26 PM, Michał Górny wrote: |
2 |
> --- |
3 |
> .travis.yml | 2 ++ |
4 |
> pym/portage/checksum.py | 15 +++++++++++++-- |
5 |
> 2 files changed, 15 insertions(+), 2 deletions(-) |
6 |
> |
7 |
> diff --git a/.travis.yml b/.travis.yml |
8 |
> index 20078530e..ebcfbeab9 100644 |
9 |
> --- a/.travis.yml |
10 |
> +++ b/.travis.yml |
11 |
> @@ -12,6 +12,8 @@ install: |
12 |
> # python3.6+ has sha3 built-in, for older versions install pysha3 |
13 |
> # (except for pypy where pysha3 is broken) |
14 |
> - "[[ ${TRAVIS_PYTHON_VERSION} == 3.[6789] || ${TRAVIS_PYTHON_VERSION} == pypy ]] || pip install pysha3" |
15 |
> + # python3.6+ has blake2 built-in, for older versions install pyblake2 |
16 |
> + - "[[ ${TRAVIS_PYTHON_VERSION} == 3.[6789] ]] || pip install pyblake2" |
17 |
> # always install pygost for Streebog |
18 |
> - pip install pygost |
19 |
> |
20 |
> diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py |
21 |
> index ff132751b..ad090ddb3 100644 |
22 |
> --- a/pym/portage/checksum.py |
23 |
> +++ b/pym/portage/checksum.py |
24 |
> @@ -27,8 +27,8 @@ import tempfile |
25 |
> # SHA512: hashlib |
26 |
> # RMD160: hashlib, pycrypto, mhash |
27 |
> # WHIRLPOOL: hashlib, mhash, bundled |
28 |
> -# BLAKE2B (512): hashlib (3.6+), pycrypto |
29 |
> -# BLAKE2S (512): hashlib (3.6+), pycrypto |
30 |
> +# BLAKE2B (512): hashlib (3.6+), pyblake2, pycrypto |
31 |
> +# BLAKE2S (512): hashlib (3.6+), pyblake2, pycrypto |
32 |
> # SHA3_256: hashlib (3.6+), pysha3, pycrypto |
33 |
> # SHA3_512: hashlib (3.6+), pysha3, pycrypto |
34 |
> |
35 |
> @@ -124,6 +124,17 @@ for local_name, hash_name in ( |
36 |
> origin='hashlib') |
37 |
> |
38 |
> |
39 |
> +# Support using pyblake2 as fallback for python<3.6 |
40 |
> +if "BLAKE2B" not in hashfunc_map or "BLAKE2S" not in hashfunc_map: |
41 |
> + try: |
42 |
> + import pyblake2 |
43 |
> + |
44 |
> + _generate_hash_function("BLAKE2B", pyblake2.blake2b, origin="pyblake2") |
45 |
> + _generate_hash_function("BLAKE2S", pyblake2.blake2s, origin="pyblake2") |
46 |
> + except ImportError: |
47 |
> + pass |
48 |
> + |
49 |
> + |
50 |
> # Support using pysha3 as fallback for python<3.6 |
51 |
> if "SHA3_256" not in hashfunc_map or "SHA3_512" not in hashfunc_map: |
52 |
> try: |
53 |
> |
54 |
|
55 |
Looks good, please merge. |
56 |
-- |
57 |
Thanks, |
58 |
Zac |