1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 setuptools, 6 isPyPy, 7 # nativeCheckInputs 8 pytest, 9 pytest-xdist, 10 # optional dependencies 11 pycryptodome, 12 safe-pysha3, 13}: 14 15buildPythonPackage rec { 16 pname = "eth-hash"; 17 version = "0.7.1"; 18 pyproject = true; 19 20 src = fetchFromGitHub { 21 owner = "ethereum"; 22 repo = "eth-hash"; 23 tag = "v${version}"; 24 hash = "sha256-91jWZDqrd7ZZlM0D/3sDokJ26NiAQ3gdeBebTV1Lq8s="; 25 }; 26 27 build-system = [ setuptools ]; 28 29 nativeCheckInputs = 30 [ 31 pytest 32 pytest-xdist 33 ] 34 ++ optional-dependencies.pycryptodome 35 # safe-pysha3 is not available on pypy 36 ++ lib.optional (!isPyPy) optional-dependencies.pysha3; 37 38 # Backends need to be tested separately and can not use hook 39 checkPhase = 40 '' 41 runHook preCheck 42 pytest tests/core tests/backends/pycryptodome 43 '' 44 + lib.optionalString (!isPyPy) '' 45 pytest tests/backends/pysha3 46 '' 47 + '' 48 runHook postCheck 49 ''; 50 51 optional-dependencies = { 52 pycryptodome = [ pycryptodome ]; 53 pysha3 = [ safe-pysha3 ]; 54 }; 55 56 meta = { 57 description = "Ethereum hashing function keccak256"; 58 homepage = "https://github.com/ethereum/eth-hash"; 59 changelog = "https://github.com/ethereum/eth-hash/blob/v${version}/docs/release_notes.rst"; 60 license = lib.licenses.mit; 61 maintainers = with lib.maintainers; [ hellwolf ]; 62 }; 63}