1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 rustPlatform,
6 fetchFromGitHub,
7 darwin,
8 libiconv,
9 openssl,
10 pkg-config,
11 protobuf,
12 attrs,
13 cachetools,
14 deprecation,
15 overrides,
16 packaging,
17 pydantic,
18 pylance,
19 requests,
20 retry,
21 tqdm,
22 aiohttp,
23 pandas,
24 polars,
25 pytest-asyncio,
26 pytestCheckHook,
27 nix-update-script,
28}:
29
30buildPythonPackage rec {
31 pname = "lancedb";
32 version = "0.14.0";
33 pyproject = true;
34
35 src = fetchFromGitHub {
36 owner = "lancedb";
37 repo = "lancedb";
38 rev = "refs/tags/python-v${version}";
39 hash = "sha256-lw2tZ26Py6JUxuetaokJKnxOv/WoLK4spxssLKxvxJA=";
40 };
41
42 buildAndTestSubdir = "python";
43
44 cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };
45
46 postPatch = ''
47 ln -s ${./Cargo.lock} Cargo.lock
48 '';
49
50 build-system = [ rustPlatform.maturinBuildHook ];
51
52 nativeBuildInputs = [
53 pkg-config
54 protobuf
55 rustPlatform.cargoSetupHook
56 ];
57
58 buildInputs =
59 [
60 libiconv
61 openssl
62 ]
63 ++ lib.optionals stdenv.hostPlatform.isDarwin (
64 with darwin.apple_sdk.frameworks;
65 [
66 IOKit
67 Security
68 SystemConfiguration
69 ]
70 );
71
72 dependencies = [
73 attrs
74 cachetools
75 deprecation
76 overrides
77 packaging
78 pydantic
79 pylance
80 requests
81 retry
82 tqdm
83 ];
84
85 pythonImportsCheck = [ "lancedb" ];
86
87 nativeCheckInputs = [
88 aiohttp
89 pandas
90 polars
91 pytest-asyncio
92 pytestCheckHook
93 ];
94
95 preCheck = ''
96 cd python/python/tests
97 '';
98
99 pytestFlagsArray = [ "-m 'not slow'" ];
100
101 disabledTests =
102 [
103 # require tantivy which is not packaged in nixpkgs
104 "test_basic"
105
106 # polars.exceptions.ComputeError: TypeError: _scan_pyarrow_dataset_impl() got multiple values for argument 'batch_size'
107 # https://github.com/lancedb/lancedb/issues/1539
108 "test_polars"
109 ]
110 ++ lib.optionals stdenv.hostPlatform.isDarwin [
111 # fail with darwin sandbox
112 "test_async_remote_db"
113 "test_http_error"
114 "test_retry_error"
115 ];
116
117 disabledTestPaths = [
118 # touch the network
119 "test_s3.py"
120 ];
121
122 passthru.updateScript = nix-update-script {
123 extraArgs = [
124 "--version-regex"
125 "python-v(.*)"
126 "--generate-lockfile"
127 "--lockfile-metadata-path"
128 "python"
129 ];
130 };
131
132 meta = {
133 description = "Developer-friendly, serverless vector database for AI applications";
134 homepage = "https://github.com/lancedb/lancedb";
135 changelog = "https://github.com/lancedb/lancedb/releases/tag/python-v${version}";
136 license = lib.licenses.asl20;
137 maintainers = with lib.maintainers; [ natsukium ];
138 };
139}