depot/third_party/nixpkgs/pkgs/development/python-modules/eth-hash/default.nix
Default email 472aeafc57 Project import generated by Copybara.
GitOrigin-RevId: c31898adf5a8ed202ce5bea9f347b1c6871f32d1
2024-10-04 18:56:33 +02:00

52 lines
1.2 KiB
Nix

{
lib,
fetchFromGitHub,
buildPythonPackage,
pythonAtLeast,
pythonOlder,
pytest,
safe-pysha3,
pycryptodome,
}:
buildPythonPackage rec {
pname = "eth-hash";
version = "0.5.2";
format = "setuptools";
disabled = pythonOlder "3.5";
src = fetchFromGitHub {
owner = "ethereum";
repo = "eth-hash";
rev = "v${version}";
hash = "sha256-6UN+kvLjjAtkmLgUaovjZC/6n3FZtXCwyXZH7ijQObU=";
};
nativeCheckInputs =
[ pytest ]
++ optional-dependencies.pycryptodome
# eth-hash can use either safe-pysha3 or pycryptodome;
# safe-pysha3 requires Python 3.9+ while pycryptodome does not.
# https://github.com/ethereum/eth-hash/issues/46#issuecomment-1314029211
++ lib.optional (pythonAtLeast "3.9") optional-dependencies.pysha3;
checkPhase =
''
pytest tests/backends/pycryptodome/
''
+ lib.optionalString (pythonAtLeast "3.9") ''
pytest tests/backends/pysha3/
'';
optional-dependencies = {
pycryptodome = [ pycryptodome ];
pysha3 = [ safe-pysha3 ];
};
meta = with lib; {
description = "Ethereum hashing function keccak256";
homepage = "https://github.com/ethereum/eth-hash";
license = licenses.mit;
maintainers = [ ];
};
}