python312Packages.guidance: fix build (#370608)

This commit is contained in:
OTABI Tomoya
2025-01-11 01:26:04 +09:00
committed by GitHub
@@ -3,21 +3,18 @@
buildPythonPackage,
fetchFromGitHub,
pytestCheckHook,
pythonOlder,
pybind11,
setuptools,
wheel,
aiohttp,
diskcache,
fastapi,
gptcache,
msal,
huggingface-hub,
jsonschema,
numpy,
openai,
ordered-set,
platformdirs,
protobuf,
pyformlang,
pydantic,
requests,
tiktoken,
torch,
@@ -29,8 +26,6 @@ buildPythonPackage rec {
version = "0.1.16";
pyproject = true;
disabled = pythonOlder "3.8";
src = fetchFromGitHub {
owner = "guidance-ai";
repo = "guidance";
@@ -38,34 +33,39 @@ buildPythonPackage rec {
hash = "sha256-dPakdT97cuLv4OwdaUFncopD5X6uXGyUjwzqn9fxnhU=";
};
nativeBuildInputs = [ pybind11 ];
build-system = [
pybind11
setuptools
wheel
];
dependencies = [
aiohttp
diskcache
fastapi
gptcache
msal
numpy
openai
ordered-set
platformdirs
protobuf
pyformlang
pydantic
requests
tiktoken
uvicorn
];
optional-dependencies = {
azureai = [ openai ];
openai = [ openai ];
schemas = [ jsonschema ];
server = [
fastapi
uvicorn
];
};
nativeCheckInputs = [
huggingface-hub
pytestCheckHook
torch
];
] ++ optional-dependencies.schemas;
pytestFlagsArray = [ "tests/unit" ];
disabledTests = [
# require network access
@@ -79,6 +79,10 @@ buildPythonPackage rec {
"test_recursion_error"
"test_openai_class_detection"
"test_openai_chat_without_roles"
"test_local_image"
"test_remote_image"
"test_image_from_bytes"
"test_remote_image_not_found"
# flaky tests
"test_remote_mock_gen" # frequently fails when building packages in parallel
@@ -86,22 +90,23 @@ buildPythonPackage rec {
disabledTestPaths = [
# require network access
"tests/library/test_gen.py"
"tests/unit/test_tokenizers.py"
];
preCheck = ''
export HOME=$TMPDIR
rm tests/conftest.py
'';
pythonImportsCheck = [ "guidance" ];
__darwinAllowLocalNetworking = true;
meta = with lib; {
meta = {
description = "Guidance language for controlling large language models";
homepage = "https://github.com/guidance-ai/guidance";
changelog = "https://github.com/guidance-ai/guidance/releases/tag/${version}";
license = licenses.mit;
maintainers = with maintainers; [ natsukium ];
changelog = "https://github.com/guidance-ai/guidance/releases/tag/${src.tag}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ natsukium ];
};
}