5aba99242e
Made with
```shell
git restore .
fd '\.nix$' pkgs/ --type f -j1 -x bash -xc "$(cat <<"EOF"
typos --no-check-filenames --write-changes "$1"
git diff --exit-code "$1" && exit
#( git diff "$1" | grep -qE "^\+ +[^# ]") && git restore "$1"
count1="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> ' | wc -l )"
count2="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> (<span style="color:#f8f8f2;"> *</span>)?<span style="color:#75715e;">.*</span>$' | wc -l )"
[[ $count1 -ne $count2 ]] && git restore "$1"
EOF
)" -- {}
```
and filtered with `GIT_DIFF_OPTS='--unified=15' git -c interactive.singleKey=true add --patch`
I initially tried using the tree-sitter cli, python bindings and even ast-grep through various means, but this is what I ended up with.
102 lines
1.9 KiB
Nix
102 lines
1.9 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
buildPythonPackage,
|
|
fetchFromGitHub,
|
|
|
|
# build-system
|
|
cargo,
|
|
pkg-config,
|
|
rustPlatform,
|
|
rustc,
|
|
|
|
# buildInputs
|
|
oniguruma,
|
|
openssl,
|
|
|
|
# tests
|
|
pytestCheckHook,
|
|
torch,
|
|
transformers,
|
|
pythonOlder,
|
|
}:
|
|
|
|
buildPythonPackage rec {
|
|
pname = "llguidance";
|
|
version = "0.6.27";
|
|
pyproject = true;
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "guidance-ai";
|
|
repo = "llguidance";
|
|
tag = "v${version}";
|
|
hash = "sha256-7XtGKqkAk6ZvWPSswLe07FaB/RYKZEi+3Lp+GBIP0OI=";
|
|
};
|
|
|
|
cargoDeps = rustPlatform.fetchCargoVendor {
|
|
inherit src;
|
|
hash = "sha256-WbPTnB1Mv9HYOrMnDhayO2V4zkuwVH/C17MdkFy57Rc=";
|
|
};
|
|
|
|
build-system = [
|
|
cargo
|
|
pkg-config
|
|
rustPlatform.cargoSetupHook
|
|
rustPlatform.maturinBuildHook
|
|
rustc
|
|
];
|
|
|
|
buildInputs = [
|
|
oniguruma
|
|
openssl
|
|
];
|
|
|
|
env = {
|
|
RUSTONIG_SYSTEM_LIBONIG = true;
|
|
};
|
|
|
|
pythonImportsCheck = [
|
|
"llguidance"
|
|
"llguidance._lib"
|
|
];
|
|
|
|
nativeCheckInputs = [
|
|
pytestCheckHook
|
|
torch
|
|
transformers
|
|
];
|
|
|
|
# Prevent python from loading the package from $src instead of the $out
|
|
preCheck = ''
|
|
rm -r python/llguidance
|
|
'';
|
|
|
|
disabledTests =
|
|
[
|
|
# Require internet access (https://huggingface.co)
|
|
"test_grammar"
|
|
"test_par_grammar"
|
|
"test_par_errors"
|
|
]
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
# torch._inductor.exc.CppCompileError: C++ compile error
|
|
# OpenMP support not found.
|
|
"test_mask_data_torch"
|
|
];
|
|
|
|
disabledTestPaths = [
|
|
# Require internet access (https://huggingface.co)
|
|
"scripts/tokenizer_test.py"
|
|
];
|
|
|
|
# As dynamo is not supported on Python 3.13+, no successful tests remain.
|
|
doCheck = pythonOlder "3.13";
|
|
|
|
meta = {
|
|
description = "Super-fast Structured Outputs";
|
|
homepage = "https://github.com/guidance-ai/llguidance";
|
|
license = lib.licenses.mit;
|
|
maintainers = with lib.maintainers; [ GaetanLepage ];
|
|
};
|
|
}
|