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/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 ''; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index f22815913e25..c6c3c64b0942 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5297,6 +5297,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 { };