Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at litex 2.7 kB view raw
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 13 14# for tests 15, pytestCheckHook 16, symbiyosys 17, yices 18, yosys 19}: 20 21buildPythonPackage rec { 22 pname = "amaranth"; 23 version = "0.3"; 24 # python setup.py --version 25 realVersion = "0.3"; 26 disabled = pythonOlder "3.6"; 27 28 src = fetchFromGitHub { 29 owner = "amaranth-lang"; 30 repo = "amaranth"; 31 rev = "39a83f4d995d16364cc9b99da646ff8db6394166"; 32 sha256 = "P9AG3t30eGeeCN5+t7mjhRoOWIGZVzWQji9eYXphjA0="; 33 }; 34 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 (fetchpatch { 51 name = "add-python-3.11-support.patch"; 52 url = "https://github.com/amaranth-lang/amaranth/commit/851546bf2d16db62663d7002bece51f07078d0a5.patch"; 53 hash = "sha256-eetlFCLqmpCfTKViD16OScJbkql1yhdi5uJGnfnpcCE="; 54 }) 55 ]; 56 57 SETUPTOOLS_SCM_PRETEND_VERSION="${realVersion}"; 58 59 nativeBuildInputs = [ 60 git 61 setuptools 62 setuptools-scm 63 ]; 64 65 propagatedBuildInputs = [ 66 jinja2 67 pyvcd 68 setuptools 69 ] ++ 70 lib.optional (pythonOlder "3.9") importlib-resources ++ 71 lib.optional (pythonOlder "3.8") importlib-metadata; 72 73 nativeCheckInputs = [ 74 pytestCheckHook 75 symbiyosys 76 yices 77 yosys 78 ]; 79 80 postPatch = '' 81 substituteInPlace setup.py \ 82 --replace "Jinja2~=2.11" "Jinja2>=2.11" \ 83 --replace "pyvcd~=0.2.2" "pyvcd" \ 84 --replace "amaranth-yosys>=0.10.*" "amaranth-yosys>=0.10" 85 86 # jinja2.contextfunction was removed in jinja2 v3.1 87 substituteInPlace amaranth/build/plat.py \ 88 --replace "@jinja2.contextfunction" "@jinja2.pass_context" 89 ''; 90 91 pythonImportsCheck = [ "amaranth" ]; 92 93 meta = with lib; { 94 description = "A modern hardware definition language and toolchain based on Python"; 95 homepage = "https://amaranth-lang.org/docs/amaranth"; 96 license = licenses.bsd2; 97 maintainers = with maintainers; [ emily thoughtpolice ]; 98 }; 99}