1{ 2 lib, 3 fetchFromGitHub, 4 buildPythonPackage, 5 pythonAtLeast, 6 pythonOlder, 7 pytest, 8 safe-pysha3, 9 pycryptodome, 10}: 11 12buildPythonPackage rec { 13 pname = "eth-hash"; 14 version = "0.5.2"; 15 format = "setuptools"; 16 disabled = pythonOlder "3.5"; 17 18 src = fetchFromGitHub { 19 owner = "ethereum"; 20 repo = "eth-hash"; 21 rev = "v${version}"; 22 hash = "sha256-6UN+kvLjjAtkmLgUaovjZC/6n3FZtXCwyXZH7ijQObU="; 23 }; 24 25 nativeCheckInputs = 26 [ pytest ] 27 ++ passthru.optional-dependencies.pycryptodome 28 # eth-hash can use either safe-pysha3 or pycryptodome; 29 # safe-pysha3 requires Python 3.9+ while pycryptodome does not. 30 # https://github.com/ethereum/eth-hash/issues/46#issuecomment-1314029211 31 ++ lib.optional (pythonAtLeast "3.9") passthru.optional-dependencies.pysha3; 32 33 checkPhase = 34 '' 35 pytest tests/backends/pycryptodome/ 36 '' 37 + lib.optionalString (pythonAtLeast "3.9") '' 38 pytest tests/backends/pysha3/ 39 ''; 40 41 passthru.optional-dependencies = { 42 pycryptodome = [ pycryptodome ]; 43 pysha3 = [ safe-pysha3 ]; 44 }; 45 46 meta = with lib; { 47 description = "The Ethereum hashing function keccak256"; 48 homepage = "https://github.com/ethereum/eth-hash"; 49 license = licenses.mit; 50 maintainers = with maintainers; [ ]; 51 }; 52}