2024-06-20 14:57:18 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
|
|
|
pytestCheckHook,
|
|
|
|
pythonOlder,
|
|
|
|
pythonAtLeast,
|
|
|
|
setuptools,
|
2024-09-19 14:19:46 +00:00
|
|
|
distutils,
|
2024-06-20 14:57:18 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2024-09-19 14:19:46 +00:00
|
|
|
pname = "tree-sitter";
|
2024-06-20 14:57:18 +00:00
|
|
|
version = "0.21.3";
|
|
|
|
pyproject = true;
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2024-06-20 14:57:18 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "tree-sitter";
|
|
|
|
repo = "py-tree-sitter";
|
|
|
|
rev = "refs/tags/v${version}";
|
|
|
|
hash = "sha256-HT1sRzDFpeelWCq1ZMeRmoUg0a3SBR7bZKxBqn4fb2g=";
|
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
build-system = [ setuptools ];
|
|
|
|
|
|
|
|
nativeCheckInputs = [ pytestCheckHook ];
|
|
|
|
|
|
|
|
pythonImportsCheck = [ "tree_sitter" ];
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
# 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 ];
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
preCheck = ''
|
|
|
|
rm -r tree_sitter
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Python bindings to the Tree-sitter parsing library";
|
|
|
|
homepage = "https://github.com/tree-sitter/py-tree-sitter";
|
|
|
|
changelog = "https://github.com/tree-sitter/py-tree-sitter/releases/tag/v${version}";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ fab ];
|
|
|
|
};
|
|
|
|
}
|