2022-06-16 17:23:12 +00:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, buildPythonPackage
|
2023-05-24 13:37:59 +00:00
|
|
|
, pythonAtLeast
|
2022-06-16 17:23:12 +00:00
|
|
|
, pythonOlder
|
|
|
|
, pytest
|
2023-02-02 18:25:31 +00:00
|
|
|
, safe-pysha3
|
2021-04-26 19:14:03 +00:00
|
|
|
, pycryptodome
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "eth-hash";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "0.5.2";
|
2022-06-16 17:23:12 +00:00
|
|
|
disabled = pythonOlder "3.5";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ethereum";
|
|
|
|
repo = "eth-hash";
|
|
|
|
rev = "v${version}";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-6UN+kvLjjAtkmLgUaovjZC/6n3FZtXCwyXZH7ijQObU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2022-06-16 17:23:12 +00:00
|
|
|
pytest
|
|
|
|
] ++ passthru.optional-dependencies.pycryptodome
|
2023-05-24 13:37:59 +00:00
|
|
|
# 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") passthru.optional-dependencies.pysha3;
|
2021-04-26 19:14:03 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
checkPhase = ''
|
|
|
|
pytest tests/backends/pycryptodome/
|
2023-05-24 13:37:59 +00:00
|
|
|
'' + lib.optionalString (pythonAtLeast "3.9") ''
|
2020-04-24 23:36:52 +00:00
|
|
|
pytest tests/backends/pysha3/
|
|
|
|
'';
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
passthru.optional-dependencies = {
|
|
|
|
pycryptodome = [ pycryptodome ];
|
2023-05-24 13:37:59 +00:00
|
|
|
pysha3 = [ safe-pysha3 ];
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "The Ethereum hashing function keccak256";
|
|
|
|
homepage = "https://github.com/ethereum/eth-hash";
|
2022-06-16 17:23:12 +00:00
|
|
|
license = licenses.mit;
|
2023-08-04 22:07:22 +00:00
|
|
|
maintainers = with maintainers; [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|