1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 rustPlatform,
6 fetchFromGitHub,
7 darwin,
8 libiconv,
9 pkg-config,
10 protobuf,
11 attrs,
12 cachetools,
13 deprecation,
14 overrides,
15 packaging,
16 pydantic,
17 pylance,
18 requests,
19 retry,
20 tqdm,
21 aiohttp,
22 pandas,
23 polars,
24 pytest-asyncio,
25 pytestCheckHook,
26}:
27
28buildPythonPackage rec {
29 pname = "lancedb";
30 version = "0.9.0";
31 pyproject = true;
32
33 src = fetchFromGitHub {
34 owner = "lancedb";
35 repo = "lancedb";
36 rev = "refs/tags/python-v${version}";
37 hash = "sha256-RWmvqGm/Bekajb/fs/PQJ2fL0Vo1Mmy+x40PKaDmIEU=";
38 };
39
40 # ratelimiter only support up to python310 and it has been removed from nixpkgs
41 patches = [ ./remove-ratelimiter.patch ];
42
43 buildAndTestSubdir = "python";
44
45 cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };
46
47 postPatch = ''
48 ln -s ${./Cargo.lock} Cargo.lock
49 '';
50
51 build-system = [ rustPlatform.maturinBuildHook ];
52
53 nativeBuildInputs = [
54 pkg-config
55 rustPlatform.cargoSetupHook
56 ];
57
58 buildInputs =
59 [
60 libiconv
61 protobuf
62 ]
63 ++ lib.optionals stdenv.isDarwin (
64 with darwin.apple_sdk.frameworks;
65 [
66 IOKit
67 Security
68 SystemConfiguration
69 ]
70 );
71
72 pythonRemoveDeps = [ "ratelimiter" ];
73
74 dependencies = [
75 attrs
76 cachetools
77 deprecation
78 overrides
79 packaging
80 pydantic
81 pylance
82 requests
83 retry
84 tqdm
85 ];
86
87 pythonImportsCheck = [ "lancedb" ];
88
89 nativeCheckInputs = [
90 aiohttp
91 pandas
92 polars
93 pytest-asyncio
94 pytestCheckHook
95 ];
96
97 preCheck = ''
98 cd python/python/tests
99 '';
100
101 pytestFlagsArray = [ "-m 'not slow'" ];
102
103 disabledTests = [
104 # require tantivy which is not packaged in nixpkgs
105 "test_basic"
106 ];
107
108 disabledTestPaths = [
109 # touch the network
110 "test_s3.py"
111 ];
112
113 meta = {
114 description = "Developer-friendly, serverless vector database for AI applications";
115 homepage = "https://github.com/lancedb/lancedb";
116 license = lib.licenses.asl20;
117 maintainers = with lib.maintainers; [ natsukium ];
118 };
119}