1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6 pdm-backend,
7 jschon,
8 pyvcd,
9 jinja2,
10 importlib-resources,
11 importlib-metadata,
12 git,
13
14 # for tests
15 pytestCheckHook,
16 sby,
17 yices,
18 yosys,
19}:
20
21buildPythonPackage rec {
22 pname = "amaranth";
23 version = "0.5.6";
24 pyproject = true;
25
26 disabled = pythonOlder "3.8";
27
28 src = fetchFromGitHub {
29 owner = "amaranth-lang";
30 repo = "amaranth";
31 tag = "v${version}";
32 hash = "sha256-fc9mCq7AgxjlR/+KKebV1GGlF5NXN/1Vee5ZLwkNjow=";
33 };
34
35 postPatch = ''
36 substituteInPlace pyproject.toml \
37 --replace-fail "pdm-backend~=2.3.0" "pdm-backend>=2.3.0"
38 '';
39
40 nativeBuildInputs = [ git ];
41
42 build-system = [ pdm-backend ];
43
44 dependencies =
45 [
46 jschon
47 jinja2
48 pyvcd
49 ]
50 ++ lib.optional (pythonOlder "3.9") importlib-resources
51 ++ lib.optional (pythonOlder "3.8") importlib-metadata;
52
53 nativeCheckInputs = [
54 pytestCheckHook
55 sby
56 yices
57 yosys
58 ];
59
60 pythonImportsCheck = [ "amaranth" ];
61
62 disabledTests = [
63 "verilog"
64 "test_reversible"
65 "test_distance"
66 ];
67
68 disabledTestPaths = [
69 # Subprocesses
70 "tests/test_examples.py"
71 # Verification failures
72 "tests/test_lib_fifo.py"
73 ];
74
75 meta = with lib; {
76 description = "Modern hardware definition language and toolchain based on Python";
77 homepage = "https://amaranth-lang.org/docs/amaranth";
78 changelog = "https://github.com/amaranth-lang/amaranth/blob/${src.tag}/docs/changes.rst";
79 license = licenses.bsd2;
80 maintainers = with maintainers; [
81 thoughtpolice
82 pbsds
83 ];
84 mainProgram = "amaranth-rpc";
85 };
86}