[packages/python3-eth_hash] - new; patched to use pycryptodomex not to conflict with Crypto module
qboosh
qboosh at pld-linux.org
Sun Jul 13 16:49:24 CEST 2025
commit 2b1cd6ee03e2da92c167c66d797e2edaf5f21bb8
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date: Sun Jul 13 16:50:52 2025 +0200
- new; patched to use pycryptodomex not to conflict with Crypto module
eth_hash-pycryptodomex.patch | 42 +++++++++++++++++++++
python3-eth_hash.spec | 88 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 130 insertions(+)
---
diff --git a/python3-eth_hash.spec b/python3-eth_hash.spec
new file mode 100644
index 0000000..7b41f63
--- /dev/null
+++ b/python3-eth_hash.spec
@@ -0,0 +1,88 @@
+#
+# Conditional build:
+%bcond_without tests # unit tests
+
+Summary: The Ethereum hashing function, keccak256, sometimes (erroneously) called sha3)
+Summary(pl.UTF-8): Funkcja haszująca Ethereum, keccak256, czasem błędnie nazywana sha3
+Name: python3-eth_hash
+Version: 0.7.1
+Release: 1
+License: MIT
+Group: Libraries/Python
+#Source0Download: https://pypi.org/simple/eth-hash/
+Source0: https://files.pythonhosted.org/packages/source/e/eth-hash/eth_hash-%{version}.tar.gz
+# Source0-md5: ea81c2690fc432ca346dce2aa182a341
+Patch0: eth_hash-pycryptodomex.patch
+URL: https://pypi.org/project/eth-hash/
+BuildRequires: python3-modules >= 1:3.8
+BuildRequires: python3-setuptools
+%if %{with tests}
+BuildRequires: python3-pycryptodomex >= 3.6.6
+BuildRequires: python3-pycryptodomex < 4
+BuildRequires: python3-pytest >= 7.0.0
+BuildRequires: python3-pytest-mock
+BuildRequires: python3-pytest-xdist >= 2.4.0
+%if "%{py3_ver}" == "3.8"
+BuildRequires: python3-pysha3 >= 1.0.0
+%else
+BuildRequires: python3-safe-pysha3 >= 1.0.3
+%endif
+%endif
+BuildRequires: rpm-pythonprov
+BuildRequires: rpmbuild(macros) >= 1.714
+%if %{with doc}
+BuildRequires: python3-sphinx_autobuild >= 2021.3.14
+BuildRequires: python3-sphinx_rtd_theme >= 1.0.0
+BuildRequires: python3-towncrier >= 24
+BuildRequires: sphinx-pdg-3 >= 6.0.0
+%endif
+Requires: python3-modules >= 1:3.8
+BuildArch: noarch
+BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+The Ethereum hashing function, keccak256, sometimes (erroneously)
+called sha3.
+
+This is a low-level library, intended to be used internally by other
+Ethereum tools.
+
+%description -l pl.UTF-8
+Funkcja haszująca Ethereum, keccak256, czasem (błędnie) nazywana sha3.
+
+Ta biblioteka jest niskopoziomowa, przeznaczona do użytku wewnętrznego
+przez inne narzędzia Ethereum.
+
+%prep
+%setup -q -n eth_hash-%{version}
+%patch -P0 -p1
+
+# pytest fails on same filenames
+%{__mv} tests/backends/pycryptodome/test_results{,-pycryptodome}.py
+%{__mv} tests/backends/pysha3/test_results{,-pysha3}.py
+# base for two above files
+%{__rm} tests/backends/test_results.py
+
+%build
+%py3_build
+
+%if %{with tests}
+# import failure tests fail on python 3.13
+PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
+PYTEST_PLUGINS=pytest_mock.plugin \
+%{__python3} -m pytest tests -k 'not test_import_auto_empty_crash and not test_load_by_env'
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%py3_install
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(644,root,root,755)
+%doc LICENSE README.md
+%{py3_sitescriptdir}/eth_hash
+%{py3_sitescriptdir}/eth_hash-%{version}-py*.egg-info
diff --git a/eth_hash-pycryptodomex.patch b/eth_hash-pycryptodomex.patch
new file mode 100644
index 0000000..07b1b47
--- /dev/null
+++ b/eth_hash-pycryptodomex.patch
@@ -0,0 +1,42 @@
+--- eth_hash-0.7.1/setup.py.orig 2025-01-13 22:29:09.000000000 +0100
++++ eth_hash-0.7.1/setup.py 2025-07-13 15:34:00.152711752 +0200
+@@ -27,7 +27,7 @@ extras_require = {
+ ],
+ # optional backends:
+ "pycryptodome": [
+- "pycryptodome>=3.6.6,<4",
++ "pycryptodomex>=3.6.6,<4",
+ ],
+ "pysha3": [
+ "pysha3>=1.0.0,<2.0.0;python_version<'3.9'",
+--- eth_hash-0.7.1/eth_hash/backends/pycryptodome.py.orig 2024-11-22 22:40:57.000000000 +0100
++++ eth_hash-0.7.1/eth_hash/backends/pycryptodome.py 2025-07-13 15:34:17.505951075 +0200
+@@ -3,7 +3,7 @@ from typing import (
+ cast,
+ )
+
+-from Crypto.Hash import (
++from Cryptodome.Hash import (
+ keccak,
+ )
+
+--- eth_hash-0.7.1/tests/core/test_import_and_version.py.orig 2024-11-22 22:40:57.000000000 +0100
++++ eth_hash-0.7.1/tests/core/test_import_and_version.py 2025-07-13 16:28:31.874987311 +0200
+@@ -25,7 +25,7 @@ def test_import_auto_empty_crash(monkeyp
+ keccak,
+ )
+
+- with mock.patch.dict("sys.modules", {"sha3": None, "Crypto.Hash": None}):
++ with mock.patch.dict("sys.modules", {"sha3": None, "Cryptodome.Hash": None}):
+ with pytest.raises(
+ ImportError, match="None of these hashing backends are installed"
+ ):
+@@ -53,7 +53,7 @@ def test_load_by_env(monkeypatch, backen
+ )
+
+ monkeypatch.setenv("ETH_HASH_BACKEND", backend)
+- with mock.patch.dict("sys.modules", {"sha3": None, "Crypto.Hash": None}):
++ with mock.patch.dict("sys.modules", {"sha3": None, "Cryptodome.Hash": None}):
+ with pytest.raises(ImportError) as excinfo:
+ keccak(b"triggered")
+ expected_msg = (
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/python3-eth_hash.git/commitdiff/2b1cd6ee03e2da92c167c66d797e2edaf5f21bb8
More information about the pld-cvs-commit
mailing list