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.7";
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-E/PJrvBmlS39KgzDz9sArq4BXwk/JmIMtdxL7MdrWlc=";
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 jschon
46 jinja2
47 pyvcd
48 ]
49 ++ lib.optional (pythonOlder "3.9") importlib-resources
50 ++ lib.optional (pythonOlder "3.8") importlib-metadata;
51
52 nativeCheckInputs = [
53 pytestCheckHook
54 sby
55 yices
56 yosys
57 ];
58
59 pythonImportsCheck = [ "amaranth" ];
60
61 disabledTests = [
62 "verilog"
63 "test_reversible"
64 "test_distance"
65 ];
66
67 disabledTestPaths = [
68 # Subprocesses
69 "tests/test_examples.py"
70 # Verification failures
71 "tests/test_lib_fifo.py"
72 ];
73
74 meta = with lib; {
75 description = "Modern hardware definition language and toolchain based on Python";
76 homepage = "https://amaranth-lang.org/docs/amaranth";
77 changelog = "https://github.com/amaranth-lang/amaranth/blob/${src.tag}/docs/changes.rst";
78 license = licenses.bsd2;
79 maintainers = with maintainers; [
80 thoughtpolice
81 pbsds
82 ];
83 mainProgram = "amaranth-rpc";
84 };
85}