ansible-later: 2.0.22 -> 2.0.23
[NixPkgs.git] / pkgs / development / python-modules / amaranth / default.nix
blob5a3f7e449e23df8c8567428799506a6721587c3f
1 { lib
2 , buildPythonPackage
3 , pythonOlder
4 , fetchFromGitHub
5 , fetchpatch
6 , setuptools
7 , setuptools-scm
8 , pyvcd
9 , jinja2
10 , importlib-resources
11 , importlib-metadata
12 , git
14 # for tests
15 , pytestCheckHook
16 , symbiyosys
17 , yices
18 , yosys
21 buildPythonPackage rec {
22   pname = "amaranth";
23   version = "0.3";
24   # python setup.py --version
25   realVersion = "0.3";
26   disabled = pythonOlder "3.6";
28   src = fetchFromGitHub {
29     owner = "amaranth-lang";
30     repo = "amaranth";
31     rev = "39a83f4d995d16364cc9b99da646ff8db6394166";
32     sha256 = "P9AG3t30eGeeCN5+t7mjhRoOWIGZVzWQji9eYXphjA0=";
33   };
35   patches = [
36     (fetchpatch {
37       name = "fix-for-setuptools-64.0.2-preparation.patch";
38       url = "https://github.com/amaranth-lang/amaranth/commit/64771a065a280fa683c1e6692383bec4f59f20fa.patch";
39       hash = "sha256-Rsh9vVvUQj9nIcrsRirmR6XwFrfZ2VMaYJ4RCQ8sBE0=";
40       # This commit removes support for Python 3.6, which is unnecessary to fix
41       # the build when using new setuptools. Include only one file, which has a
42       # harmless comment change so that the subsequent patch applies cleanly.
43       includes = ["amaranth/_toolchain/cxx.py"];
44     })
45     (fetchpatch {
46       name = "fix-for-setuptools-64.0.2.patch";
47       url = "https://github.com/amaranth-lang/amaranth/pull/722/commits/e5a56b07c568e5f4cc2603eefebd14c5cc4e13d8.patch";
48       hash = "sha256-C8FyMSKHA7XsEMpO9eYNZx/X5rGaK7p3eXP+jSb6wVg=";
49     })
50   ];
52   SETUPTOOLS_SCM_PRETEND_VERSION="${realVersion}";
54   nativeBuildInputs = [
55     git
56     setuptools-scm
57   ];
59   propagatedBuildInputs = [
60     jinja2
61     pyvcd
62     setuptools
63   ] ++
64     lib.optional (pythonOlder "3.9") importlib-resources ++
65     lib.optional (pythonOlder "3.8") importlib-metadata;
67   checkInputs = [
68     pytestCheckHook
69     symbiyosys
70     yices
71     yosys
72   ];
74   postPatch = ''
75     substituteInPlace setup.py \
76       --replace "Jinja2~=2.11" "Jinja2>=2.11" \
77       --replace "pyvcd~=0.2.2" "pyvcd"
79     # jinja2.contextfunction was removed in jinja2 v3.1
80     substituteInPlace amaranth/build/plat.py \
81       --replace "@jinja2.contextfunction" "@jinja2.pass_context"
82   '';
84   pythonImportsCheck = [ "amaranth" ];
86   meta = with lib; {
87     description = "A modern hardware definition language and toolchain based on Python";
88     homepage = "https://amaranth-lang.org/docs/amaranth";
89     license = licenses.bsd2;
90     maintainers = with maintainers; [ emily thoughtpolice ];
91   };