nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # tests
10 pytestCheckHook,
11 tree-sitter-python,
12 tree-sitter-rust,
13 tree-sitter-html,
14 tree-sitter-javascript,
15 tree-sitter-json,
16}:
17
18buildPythonPackage rec {
19 pname = "tree-sitter";
20 version = "0.25.2";
21 pyproject = true;
22
23 src = fetchFromGitHub {
24 owner = "tree-sitter";
25 repo = "py-tree-sitter";
26 tag = "v${version}";
27 hash = "sha256-MgiVxq9MUaOkNNgn46g2Cy7/IUx/yatKSR1vE6LscKg=";
28 fetchSubmodules = true;
29 };
30
31 build-system = [ setuptools ];
32
33 nativeCheckInputs = [
34 pytestCheckHook
35 tree-sitter-python
36 tree-sitter-rust
37 tree-sitter-html
38 tree-sitter-javascript
39 tree-sitter-json
40 ];
41
42 pythonImportsCheck = [ "tree_sitter" ];
43
44 preCheck = ''
45 # https://github.com/NixOS/nixpkgs/issues/255262#issuecomment-1721265871
46 rm -r tree_sitter
47 '';
48
49 disabledTests = [
50 # Test fails only in the Nix sandbox, with:
51 #
52 # AssertionError: Lists differ: ['', '', ''] != ['graph {\n', 'label="new_parse"\n', '}\n']
53 "test_dot_graphs"
54 ];
55
56 meta = {
57 description = "Python bindings to the Tree-sitter parsing library";
58 homepage = "https://github.com/tree-sitter/py-tree-sitter";
59 changelog = "https://github.com/tree-sitter/py-tree-sitter/releases/tag/${src.tag}";
60 license = lib.licenses.mit;
61 maintainers = with lib.maintainers; [ fab ];
62 };
63}