python3Packages.tree-sitter-language-pack: add check and update script

This commit is contained in:
Zexin Yuan
2025-05-20 17:47:48 +08:00
parent 501b5b8fe3
commit 17d13f6906
@@ -2,6 +2,8 @@
lib,
buildPythonPackage,
fetchPypi,
python,
nix-update-script,
# build-system
cython,
@@ -53,8 +55,30 @@ buildPythonPackage rec {
"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";