From f97a1c5460c3ac4286f68681054986166edc284c Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 3 Aug 2024 09:25:06 -0500 Subject: [PATCH 1/2] python312Packages.tree-sitter0_21: remove Python 3.12 limit distutils was removed from the standard library in Python 3.12, but it is required to propagate to tree-sitter0_21's dependent applications. Removing the limitation on the package and adding distutils to the dependencies allows this library to be useful in Python 3.12. --- .../python-modules/tree-sitter0_21/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/tree-sitter0_21/default.nix b/pkgs/development/python-modules/tree-sitter0_21/default.nix index 665f7d6b56ce..2e0dde0da3a6 100644 --- a/pkgs/development/python-modules/tree-sitter0_21/default.nix +++ b/pkgs/development/python-modules/tree-sitter0_21/default.nix @@ -6,6 +6,7 @@ pythonOlder, pythonAtLeast, setuptools, + distutils, }: buildPythonPackage rec { @@ -13,8 +14,7 @@ buildPythonPackage rec { version = "0.21.3"; pyproject = true; - # https://github.com/tree-sitter/py-tree-sitter/issues/209 - disabled = pythonAtLeast "3.12" || pythonOlder "3.7"; + disabled = pythonOlder "3.7"; src = fetchFromGitHub { owner = "tree-sitter"; @@ -30,6 +30,10 @@ buildPythonPackage rec { pythonImportsCheck = [ "tree_sitter" ]; + # Needed explicitly for Python >= 3.12 as tree-sitter provides + # calls to distutils functions to compile language files + dependencies = lib.optionals (pythonAtLeast "3.12") [ distutils ]; + preCheck = '' rm -r tree_sitter ''; From ebf0719c6599e22fe2f3153d7c1c7985e920fe75 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sat, 3 Aug 2024 09:31:43 -0500 Subject: [PATCH 2/2] python312Packages.grep-ast: init at 0.3.3 --- .../python-modules/grep-ast/default.nix | 41 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 43 insertions(+) create mode 100644 pkgs/development/python-modules/grep-ast/default.nix diff --git a/pkgs/development/python-modules/grep-ast/default.nix b/pkgs/development/python-modules/grep-ast/default.nix new file mode 100644 index 000000000000..01d164bacdc1 --- /dev/null +++ b/pkgs/development/python-modules/grep-ast/default.nix @@ -0,0 +1,41 @@ +{ + buildPythonPackage, + fetchPypi, + lib, + + pathspec, + pytestCheckHook, + setuptools, + tree-sitter-languages, +}: + +buildPythonPackage rec { + pname = "grep-ast"; + version = "0.3.3"; + pyproject = true; + + src = fetchPypi { + inherit version; + pname = "grep_ast"; + hash = "sha256-QriIfVcwHcVWNDaPjVSenEnJE9r7TRnJtUw922BPzPQ="; + }; + + build-system = [ setuptools ]; + + dependencies = [ + pathspec + tree-sitter-languages + ]; + + nativeCheckInputs = [ pytestCheckHook ]; + + pythonImportsCheck = [ "grep_ast" ]; + + meta = { + homepage = "https://github.com/paul-gauthier/grep-ast"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ greg ]; + description = "Python implementation of the ast-grep tool"; + mainProgram = "grep-ast"; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 0fd0de0df609..5d724731d9e3 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5295,6 +5295,8 @@ self: super: with self; { gremlinpython = callPackage ../development/python-modules/gremlinpython { }; + grep-ast = callPackage ../development/python-modules/grep-ast { }; + greynoise = callPackage ../development/python-modules/greynoise { }; growattserver = callPackage ../development/python-modules/growattserver { };