Skip to content

Commit e54888c

Browse files
committed
python3Packages.chromadb: refactor
1 parent 0e9e520 commit e54888c

File tree

1 file changed

+61
-29
lines changed

1 file changed

+61
-29
lines changed

pkgs/development/python-modules/chromadb/default.nix

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,71 @@
11
{
22
lib,
33
stdenv,
4-
bcrypt,
5-
build,
64
buildPythonPackage,
5+
fetchFromGitHub,
6+
7+
# build-system
8+
setuptools-scm,
9+
setuptools,
10+
11+
# build inputs
712
cargo,
8-
chroma-hnswlib,
13+
pkg-config,
14+
protobuf,
15+
rustc,
16+
rustPlatform,
17+
openssl,
18+
19+
# dependencies
20+
bcrypt,
21+
build,
922
fastapi,
10-
fetchFromGitHub,
1123
grpcio,
1224
httpx,
13-
hypothesis,
1425
importlib-resources,
1526
kubernetes,
1627
mmh3,
17-
nixosTests,
1828
numpy,
1929
onnxruntime,
20-
openssl,
2130
opentelemetry-api,
2231
opentelemetry-exporter-otlp-proto-grpc,
2332
opentelemetry-instrumentation-fastapi,
2433
opentelemetry-sdk,
2534
orjson,
2635
overrides,
27-
pkg-config,
2836
posthog,
29-
protobuf,
30-
psutil,
3137
pulsar-client,
3238
pydantic,
3339
pypika,
34-
pytest-asyncio,
35-
pytestCheckHook,
36-
pythonOlder,
3740
pyyaml,
3841
requests,
39-
rustc,
40-
rustPlatform,
41-
setuptools-scm,
42-
setuptools,
4342
tenacity,
4443
tokenizers,
4544
tqdm,
4645
typer,
4746
typing-extensions,
4847
uvicorn,
4948
zstd,
49+
50+
# optional dependencies
51+
chroma-hnswlib,
52+
53+
# tests
54+
hypothesis,
55+
psutil,
56+
pytest-asyncio,
57+
pytestCheckHook,
58+
59+
# passthru
60+
nixosTests,
61+
nix-update-script,
5062
}:
5163

5264
buildPythonPackage rec {
5365
pname = "chromadb";
5466
version = "0.5.20";
5567
pyproject = true;
5668

57-
disabled = pythonOlder "3.9";
58-
5969
src = fetchFromGitHub {
6070
owner = "chroma-core";
6171
repo = "chroma";
@@ -64,7 +74,8 @@ buildPythonPackage rec {
6474
};
6575

6676
cargoDeps = rustPlatform.fetchCargoVendor {
67-
inherit pname version src;
77+
inherit src;
78+
name = "${pname}-${version}-vendor";
6879
hash = "sha256-ZtCTg8qNCiqlH7RsZxaWUNAoazdgmXP2GtpjDpRdvbk=";
6980
};
7081

@@ -130,21 +141,29 @@ buildPythonPackage rec {
130141
pytestCheckHook
131142
];
132143

133-
pythonImportsCheck = [ "chromadb" ];
144+
# Disable on aarch64-linux due to broken onnxruntime
145+
# https://github.com/microsoft/onnxruntime/issues/10038
146+
pythonImportsCheck = lib.optionals (stdenv.hostPlatform.system != "aarch64-linux") [ "chromadb" ];
147+
148+
# Test collection breaks on aarch64-linux
149+
doCheck = stdenv.hostPlatform.system != "aarch64-linux";
134150

135151
env = {
136152
ZSTD_SYS_USE_PKG_CONFIG = true;
137153
};
138154

139-
pytestFlagsArray = [ "-x" ];
155+
pytestFlagsArray = [
156+
"-x" # these are slow tests, so stop on the first failure
157+
"-v"
158+
];
140159

141160
preCheck = ''
142161
(($(ulimit -n) < 1024)) && ulimit -n 1024
143162
export HOME=$(mktemp -d)
144163
'';
145164

146165
disabledTests = [
147-
# Tests are laky / timing sensitive
166+
# Tests are flaky / timing sensitive
148167
"test_fastapi_server_token_authn_allows_when_it_should_allow"
149168
"test_fastapi_server_token_authn_rejects_when_it_should_reject"
150169
# Issue with event loop
@@ -166,17 +185,30 @@ buildPythonPackage rec {
166185

167186
__darwinAllowLocalNetworking = true;
168187

169-
passthru.tests = {
170-
inherit (nixosTests) chromadb;
188+
passthru = {
189+
tests = {
190+
inherit (nixosTests) chromadb;
191+
};
192+
193+
updateScript = nix-update-script {
194+
# we have to update both the python hash and the cargo one,
195+
# so use nix-update-script
196+
extraArgs = [
197+
"--versionRegex"
198+
"([0-9].+)"
199+
];
200+
};
171201
};
172202

173-
meta = with lib; {
203+
meta = {
174204
description = "AI-native open-source embedding database";
175205
homepage = "https://github.com/chroma-core/chroma";
176206
changelog = "https://github.com/chroma-core/chroma/releases/tag/${version}";
177-
license = licenses.asl20;
178-
maintainers = with maintainers; [ fab ];
207+
license = lib.licenses.asl20;
208+
maintainers = with lib.maintainers; [
209+
fab
210+
sarahec
211+
];
179212
mainProgram = "chroma";
180-
broken = stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64;
181213
};
182214
}

0 commit comments

Comments
 (0)