2023-04-12 12:48:02 +00:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
2024-04-21 15:54:59 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
2023-04-12 12:48:02 +00:00
|
|
|
, pytestCheckHook
|
|
|
|
, pythonOlder
|
|
|
|
, setuptools
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "tree-sitter";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "0.21.1";
|
|
|
|
pyproject = true;
|
2023-04-12 12:48:02 +00:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.7";
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "tree-sitter";
|
|
|
|
repo = "py-tree-sitter";
|
|
|
|
rev = "refs/tags/v${version}";
|
|
|
|
hash = "sha256-U4ZdU0lxjZO/y0q20bG5CLKipnfpaxzV3AFR6fGS7m4=";
|
|
|
|
fetchSubmodules = true;
|
2023-04-12 12:48:02 +00:00
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
patches = [
|
|
|
|
# Replace distutils with setuptools, https://github.com/tree-sitter/py-tree-sitter/pull/214
|
|
|
|
(fetchpatch {
|
|
|
|
name = "replace-distutils.patch";
|
|
|
|
url = "https://github.com/tree-sitter/py-tree-sitter/commit/80d3cae493c4a47e49cc1d2ebab0a8eaf7617825.patch";
|
|
|
|
hash = "sha256-00coI8/COpYMiSflAECwh6yJCMJj/ucFEn18Npj2g+Q=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-04-12 12:48:02 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
setuptools
|
|
|
|
];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
2023-04-12 12:48:02 +00:00
|
|
|
|
|
|
|
pythonImportsCheck = [
|
|
|
|
"tree_sitter"
|
|
|
|
];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
preCheck = ''
|
|
|
|
rm -r tree_sitter
|
|
|
|
'';
|
|
|
|
|
2023-04-12 12:48:02 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Python bindings to the Tree-sitter parsing library";
|
|
|
|
homepage = "https://github.com/tree-sitter/py-tree-sitter";
|
2024-01-02 11:29:13 +00:00
|
|
|
changelog = "https://github.com/tree-sitter/py-tree-sitter/releases/tag/v${version}";
|
2023-04-12 12:48:02 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ fab ];
|
|
|
|
};
|
|
|
|
}
|