<commit_before>{ 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 thoughtpolice ];
  };
}<commit_msg>amaranth: patch out use of deprecated jinja2 function<commit_after>{ 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"

    # jinja2.contextfunction was removed in jinja2 v3.1
    substituteInPlace amaranth/build/plat.py \
      --replace "@jinja2.contextfunction" "@jinja2.pass_context"
  '';

  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 thoughtpolice ];
  };
}
{'fraction_non_alphanumeric': 0.12053717654765804, 'fraction_numerical': 0.04290861447756305, 'mean_word_length': 3.3380681818181817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '671686', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1160, 'n_words': 212}