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";
|
2021-09-18 10:52:07 +00:00
|
|
|
version = "0.3.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-03-15 16:39:30 +00:00
|
|
|
hash = "sha256-LMDtFUrsPYgj/Fl9aBW1todlj1D3LlFxAkzNFAzCGLQ=";
|
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;
|
|
|
|
maintainers = with maintainers; [ SuperSandro2000 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|