python313Packages.traits: fix build (#373698)
[NixPkgs.git] / pkgs / development / python-modules / guidance / default.nix
blob38eebb5654ae09fbe2385f81751412b90d944d04
2   lib,
3   buildPythonPackage,
4   fetchFromGitHub,
5   pytestCheckHook,
6   pybind11,
7   setuptools,
8   diskcache,
9   fastapi,
10   huggingface-hub,
11   jsonschema,
12   numpy,
13   openai,
14   ordered-set,
15   platformdirs,
16   protobuf,
17   pydantic,
18   requests,
19   tiktoken,
20   torch,
21   uvicorn,
24 buildPythonPackage rec {
25   pname = "guidance";
26   version = "0.1.16";
27   pyproject = true;
29   src = fetchFromGitHub {
30     owner = "guidance-ai";
31     repo = "guidance";
32     tag = version;
33     hash = "sha256-dPakdT97cuLv4OwdaUFncopD5X6uXGyUjwzqn9fxnhU=";
34   };
36   build-system = [
37     pybind11
38     setuptools
39   ];
41   dependencies = [
42     diskcache
43     numpy
44     ordered-set
45     platformdirs
46     protobuf
47     pydantic
48     requests
49     tiktoken
50   ];
52   optional-dependencies = {
53     azureai = [ openai ];
54     openai = [ openai ];
55     schemas = [ jsonschema ];
56     server = [
57       fastapi
58       uvicorn
59     ];
60   };
62   nativeCheckInputs = [
63     huggingface-hub
64     pytestCheckHook
65     torch
66   ] ++ optional-dependencies.schemas;
68   pytestFlagsArray = [ "tests/unit" ];
70   disabledTests = [
71     # require network access
72     "test_select_simple"
73     "test_commit_point"
74     "test_token_healing"
75     "test_fstring"
76     "test_fstring_custom"
77     "test_token_count"
78     "test_gpt2"
79     "test_recursion_error"
80     "test_openai_class_detection"
81     "test_openai_chat_without_roles"
82     "test_local_image"
83     "test_remote_image"
84     "test_image_from_bytes"
85     "test_remote_image_not_found"
87     # flaky tests
88     "test_remote_mock_gen" # frequently fails when building packages in parallel
89   ];
91   disabledTestPaths = [
92     # require network access
93     "tests/unit/test_tokenizers.py"
94   ];
96   preCheck = ''
97     export HOME=$TMPDIR
98     rm tests/conftest.py
99   '';
101   pythonImportsCheck = [ "guidance" ];
103   __darwinAllowLocalNetworking = true;
105   meta = {
106     description = "Guidance language for controlling large language models";
107     homepage = "https://github.com/guidance-ai/guidance";
108     changelog = "https://github.com/guidance-ai/guidance/releases/tag/${src.tag}";
109     license = lib.licenses.mit;
110     maintainers = with lib.maintainers; [ natsukium ];
111   };