about summary refs log tree commit diff
path: root/pkgs/development/python-modules/cairo-lang/default.nix
blob: f1da79151f424ee91c97da801622e1c89f0cdcd9 (plain) (blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{ lib
, aiohttp
, buildPythonPackage
, cachetools
, ecdsa
, eth-hash
, fastecdsa
, fetchzip
, frozendict
, gmp
, lark
, marshmallow
, marshmallow-dataclass
, marshmallow-enum
, marshmallow-oneofschema
, mpmath
, numpy
, pipdeptree
, prometheus-client
, pytest
, pytest-asyncio
, pytestCheckHook
, pythonOlder
, pythonRelaxDepsHook
, pyyaml
, setuptools
, sympy
, typeguard
, web3
}:

buildPythonPackage rec {
  pname = "cairo-lang";
  version = "0.10.0";
  format = "setuptools";

  disabled = pythonOlder "3.7";

  src = fetchzip {
    url = "https://github.com/starkware-libs/cairo-lang/releases/download/v${version}/cairo-lang-${version}.zip";
    sha256 = "sha256-+PE7RSKEGADbue63FoT6UBOwURJs7lBNkL7aNlpSxP8=";
  };

  # TODO: remove a substantial part when https://github.com/starkware-libs/cairo-lang/pull/88/files is merged.
  postPatch = ''
    substituteInPlace requirements.txt \
      --replace "lark-parser" "lark"

    substituteInPlace starkware/cairo/lang/compiler/parser_transformer.py \
      --replace 'value, meta' 'meta, value' \
      --replace 'value: Tuple[CommaSeparatedWithNotes], meta' 'meta, value: Tuple[CommaSeparatedWithNotes]'
    substituteInPlace starkware/cairo/lang/compiler/parser.py \
      --replace 'standard' 'basic'
  '';

  nativeBuildInputs = [
    pythonRelaxDepsHook
  ];

  buildInputs = [
    gmp
  ];

  propagatedBuildInputs = [
    aiohttp
    cachetools
    setuptools
    ecdsa
    fastecdsa
    sympy
    mpmath
    numpy
    typeguard
    frozendict
    prometheus-client
    marshmallow
    marshmallow-enum
    marshmallow-dataclass
    marshmallow-oneofschema
    pipdeptree
    lark
    web3
    eth-hash
    pyyaml
  ] ++ eth-hash.optional-dependencies.pycryptodome;

  nativeCheckInputs = [
    pytest-asyncio
    pytestCheckHook
  ];

  pythonRelaxDeps = [
    "frozendict"
  ];

  pythonRemoveDeps = [
    # TODO: pytest and pytest-asyncio must be removed as they are check inputs
    "pytest"
    "pytest-asyncio"
  ];

  # There seems to be no test included in the ZIP release…
  # Cloning from GitHub is harder because they use a custom CMake setup
  # TODO(raitobezarius): upstream was pinged out of band about it.
  doCheck = false;

  meta = with lib; {
    description = "Tooling for Cairo language";
    homepage = "https://github.com/starkware/cairo-lang";
    license = licenses.mit;
    maintainers = with maintainers; [ raitobezarius ];
  };
}