python3Packages.tree-sitter-language-pack: 0.6.1 -> 0.7.3, add check and update script (#409016)

This commit is contained in:
Yt
2025-05-20 07:32:09 -04:00
committed by GitHub
2 changed files with 34 additions and 7 deletions
@@ -285,9 +285,6 @@ let
"test_main_exit_calls_version_check"
# AssertionError: assert 2 == 1
"test_simple_send_non_retryable_error"
# Broken tests (Aider-AI/aider#3679)
"test_language_ocaml"
"test_language_ocaml_interface"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# Tests fails on darwin
@@ -2,6 +2,8 @@
lib,
buildPythonPackage,
fetchPypi,
python,
nix-update-script,
# build-system
cython,
@@ -17,7 +19,7 @@
buildPythonPackage rec {
pname = "tree-sitter-language-pack";
version = "0.6.1";
version = "0.7.3";
pyproject = true;
# Using the GitHub sources necessitates fetching the treesitter grammar parsers by using a vendored script:
@@ -26,7 +28,7 @@ buildPythonPackage rec {
src = fetchPypi {
pname = "tree_sitter_language_pack";
inherit version;
hash = "sha256-pGNfW2ubZCVi2QHk6qJfyClJ1mDIi5R1Pm1GfZY0Ark=";
hash = "sha256-SROctgfYE1LTOtGOV1IPwQV6AJlVyczO1WYHzBjmo/0=";
};
build-system = [
@@ -42,13 +44,41 @@ buildPythonPackage rec {
tree-sitter-yaml
];
prePatch = ''
# Remove the packaged bindings, which only work on Linux and prevent the build from succeeding
# https://github.com/Goldziher/tree-sitter-language-pack/issues/46
rm -rf tree_sitter_language_pack/bindings/*.so
'';
pythonImportsCheck = [
"tree_sitter_language_pack"
"tree_sitter_language_pack.bindings"
];
# No tests in the pypi archive
doCheck = false;
# No tests in the pypi archive, we add a test to check that all bindings can be imported
checkPhase = ''
runHook preCheck
cat <<EOF > test-import-bindings.py
import sys
import os
if (cwd := os.getcwd()) in sys.path:
# remove current working directory from sys.path, use PYTHONPATH instead
sys.path.remove(cwd)
from typing import get_args
from tree_sitter_language_pack import SupportedLanguage, get_binding
for lang in get_args(SupportedLanguage):
get_binding(lang)
EOF
${python.interpreter} test-import-bindings.py
runHook postCheck
'';
passthru.updateScript = nix-update-script { };
meta = {
description = "Comprehensive collection of tree-sitter languages";