1{
2 lib,
3 stdenv,
4 bcrypt,
5 build,
6 buildPythonPackage,
7 cargo,
8 chroma-hnswlib,
9 darwin,
10 fastapi,
11 fetchFromGitHub,
12 grpcio,
13 hypothesis,
14 importlib-resources,
15 kubernetes,
16 mmh3,
17 numpy,
18 onnxruntime,
19 openssl,
20 opentelemetry-api,
21 opentelemetry-exporter-otlp-proto-grpc,
22 opentelemetry-instrumentation-fastapi,
23 opentelemetry-sdk,
24 orjson,
25 overrides,
26 pkg-config,
27 posthog,
28 protobuf,
29 pulsar-client,
30 pydantic,
31 pypika,
32 pytest-asyncio,
33 pytestCheckHook,
34 pythonOlder,
35 pythonRelaxDepsHook,
36 pyyaml,
37 requests,
38 rustc,
39 rustPlatform,
40 setuptools,
41 setuptools-scm,
42 tenacity,
43 tokenizers,
44 tqdm,
45 typer,
46 typing-extensions,
47 uvicorn,
48 zstd,
49}:
50
51buildPythonPackage rec {
52 pname = "chromadb";
53 version = "0.5.0";
54 pyproject = true;
55
56 disabled = pythonOlder "3.9";
57
58 src = fetchFromGitHub {
59 owner = "chroma-core";
60 repo = "chroma";
61 rev = "refs/tags/${version}";
62 hash = "sha256-gM+fexjwifF3evR8jZvMbIDz655RFKPUizrsB2q5tbw=";
63 };
64
65 cargoDeps = rustPlatform.fetchCargoTarball {
66 inherit src;
67 name = "${pname}-${version}";
68 hash = "sha256-zyiFv/gswGupm7Y8BhviklqJzM914v0QyUsRwbGKZ48=";
69 };
70
71 pythonRelaxDeps = [ "orjson" ];
72
73 nativeBuildInputs = [
74 cargo
75 pkg-config
76 protobuf
77 pythonRelaxDepsHook
78 rustc
79 rustPlatform.cargoSetupHook
80 setuptools
81 setuptools-scm
82 ];
83
84 buildInputs = [
85 openssl
86 zstd
87 ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
88
89 propagatedBuildInputs = [
90 bcrypt
91 build
92 chroma-hnswlib
93 fastapi
94 grpcio
95 importlib-resources
96 kubernetes
97 mmh3
98 numpy
99 onnxruntime
100 opentelemetry-api
101 opentelemetry-exporter-otlp-proto-grpc
102 opentelemetry-instrumentation-fastapi
103 opentelemetry-sdk
104 orjson
105 overrides
106 posthog
107 pulsar-client
108 pydantic
109 pypika
110 pyyaml
111 requests
112 tenacity
113 tokenizers
114 tqdm
115 typer
116 typing-extensions
117 uvicorn
118 ];
119
120 nativeCheckInputs = [
121 hypothesis
122 pytest-asyncio
123 pytestCheckHook
124 ];
125
126 pythonImportsCheck = [ "chromadb" ];
127
128 env = {
129 ZSTD_SYS_USE_PKG_CONFIG = true;
130 };
131
132 pytestFlagsArray = [ "-x" ];
133
134 preCheck = ''
135 (($(ulimit -n) < 1024)) && ulimit -n 1024
136 export HOME=$(mktemp -d)
137 '';
138
139 disabledTestPaths = [
140 # Tests require network access
141 "chromadb/test/property/test_cross_version_persist.py"
142 "chromadb/test/auth/test_simple_rbac_authz.py"
143 "chromadb/test/ef/test_default_ef.py"
144 "chromadb/test/test_api.py"
145 "chromadb/test/property/"
146 "chromadb/test/stress/"
147 ];
148
149 __darwinAllowLocalNetworking = true;
150
151 meta = with lib; {
152 description = "The AI-native open-source embedding database";
153 mainProgram = "chroma";
154 homepage = "https://github.com/chroma-core/chroma";
155 changelog = "https://github.com/chroma-core/chroma/releases/tag/${version}";
156 license = licenses.asl20;
157 maintainers = with maintainers; [ fab ];
158 };
159}