about summary refs log tree commit diff
path: root/pkgs/development/python-modules/amaranth
diff options
context:
space:
mode:
authorleo60228 <leo@60228.dev>2022-01-01 23:55:07 -0500
committerAustin Seipp <aseipp@pobox.com>2022-01-11 13:56:20 -0600
commit34d3df28d58878dcfacb50ad55f24af509320e29 (patch)
tree413ca579923dbd9dc3a50dd3ff9b7b5d0e3c879c /pkgs/development/python-modules/amaranth
parent7c50aeaf11379df18f918e965f75266414d0da9b (diff)
amaranth: rename from nmigen, unstable-2021-02-09 -> 0.3
Cherry-picked from #153163.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'pkgs/development/python-modules/amaranth')
-rw-r--r--pkgs/development/python-modules/amaranth/default.nix70
1 files changed, 70 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/amaranth/default.nix b/pkgs/development/python-modules/amaranth/default.nix
new file mode 100644
index 0000000000000..a01d5eb42f737
--- /dev/null
+++ b/pkgs/development/python-modules/amaranth/default.nix
@@ -0,0 +1,70 @@
+{ lib
+, buildPythonPackage
+, pythonOlder
+, fetchFromGitHub
+, setuptools
+, setuptools-scm
+, pyvcd
+, jinja2
+, importlib-resources
+, importlib-metadata
+, git
+
+# for tests
+, pytestCheckHook
+, symbiyosys
+, yices
+, yosys
+}:
+
+buildPythonPackage rec {
+  pname = "amaranth";
+  version = "0.3";
+  # python setup.py --version
+  realVersion = "0.3";
+  disabled = pythonOlder "3.6";
+
+  src = fetchFromGitHub {
+    owner = "amaranth-lang";
+    repo = "amaranth";
+    rev = "39a83f4d995d16364cc9b99da646ff8db6394166";
+    sha256 = "P9AG3t30eGeeCN5+t7mjhRoOWIGZVzWQji9eYXphjA0=";
+  };
+
+  SETUPTOOLS_SCM_PRETEND_VERSION="${realVersion}";
+
+  nativeBuildInputs = [
+    git
+    setuptools-scm
+  ];
+
+  propagatedBuildInputs = [
+    jinja2
+    pyvcd
+    setuptools
+  ] ++
+    lib.optional (pythonOlder "3.9") importlib-resources ++
+    lib.optional (pythonOlder "3.8") importlib-metadata;
+
+  checkInputs = [
+    pytestCheckHook
+    symbiyosys
+    yices
+    yosys
+  ];
+
+  postPatch = ''
+    substituteInPlace setup.py \
+      --replace "Jinja2~=2.11" "Jinja2>=2.11" \
+      --replace "pyvcd~=0.2.2" "pyvcd"
+  '';
+
+  pythonImportsCheck = [ "amaranth" ];
+
+  meta = with lib; {
+    description = "A modern hardware definition language and toolchain based on Python";
+    homepage = "https://amaranth-lang.org/docs/amaranth";
+    license = licenses.bsd2;
+    maintainers = with maintainers; [ emily ];
+  };
+}