summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/eth-hash/default.nix
blob: 86ba11f3c01961b0c22fe55561387602bfbc8ea8 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools,
  isPyPy,
  # nativeCheckInputs
  pytest,
  pytest-xdist,
  # optional dependencies
  pycryptodome,
  safe-pysha3,
}:

buildPythonPackage rec {
  pname = "eth-hash";
  version = "0.7.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "ethereum";
    repo = "eth-hash";
    tag = "v${version}";
    hash = "sha256-91jWZDqrd7ZZlM0D/3sDokJ26NiAQ3gdeBebTV1Lq8s=";
  };

  build-system = [ setuptools ];

  nativeCheckInputs =
    [
      pytest
      pytest-xdist
    ]
    ++ optional-dependencies.pycryptodome
    # safe-pysha3 is not available on pypy
    ++ lib.optional (!isPyPy) optional-dependencies.pysha3;

  # Backends need to be tested separately and can not use hook
  checkPhase =
    ''
      runHook preCheck
      pytest tests/core tests/backends/pycryptodome
    ''
    + lib.optionalString (!isPyPy) ''
      pytest tests/backends/pysha3
    ''
    + ''
      runHook postCheck
    '';

  optional-dependencies = {
    pycryptodome = [ pycryptodome ];
    pysha3 = [ safe-pysha3 ];
  };

  meta = {
    description = "Ethereum hashing function keccak256";
    homepage = "https://github.com/ethereum/eth-hash";
    changelog = "https://github.com/ethereum/eth-hash/blob/v${version}/docs/release_notes.rst";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ hellwolf ];
  };
}