1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 rustPlatform,
7
8 # buildInputs
9 openssl,
10
11 # nativeBuildInputs
12 pkg-config,
13 protobuf,
14
15 # dependencies
16 deprecation,
17 overrides,
18 packaging,
19 pyarrow,
20 pydantic,
21 tqdm,
22
23 # tests
24 aiohttp,
25 pandas,
26 polars,
27 pylance,
28 pytest-asyncio,
29 pytestCheckHook,
30 duckdb,
31 nix-update-script,
32}:
33
34buildPythonPackage rec {
35 pname = "lancedb";
36 version = "0.21.2";
37 pyproject = true;
38
39 src = fetchFromGitHub {
40 owner = "lancedb";
41 repo = "lancedb";
42 tag = "python-v${version}";
43 hash = "sha256-ZPVkMlZz6lSF4ZCIX6fGcfCvni3kXCLPLXZqZw7icpE=";
44 };
45
46 buildAndTestSubdir = "python";
47
48 cargoDeps = rustPlatform.fetchCargoVendor {
49 inherit pname version src;
50 hash = "sha256-Q3ejJsddHLGGbw3peLRtjPqBrS6fNi0C3K2UWpcM/4k=";
51 };
52
53 build-system = [ rustPlatform.maturinBuildHook ];
54
55 nativeBuildInputs = [
56 pkg-config
57 protobuf
58 rustPlatform.cargoSetupHook
59 ];
60
61 buildInputs = [
62 openssl
63 ];
64
65 pythonRelaxDeps = [
66 # pylance is pinned to a specific release
67 "pylance"
68 ];
69
70 dependencies = [
71 deprecation
72 overrides
73 packaging
74 pyarrow
75 pydantic
76 tqdm
77 ];
78
79 pythonImportsCheck = [ "lancedb" ];
80
81 nativeCheckInputs = [
82 aiohttp
83 duckdb
84 pandas
85 polars
86 pylance
87 pytest-asyncio
88 pytestCheckHook
89 ];
90
91 preCheck = ''
92 cd python/python/tests
93 '';
94
95 disabledTestMarks = [ "slow" ];
96
97 disabledTests = [
98 # require tantivy which is not packaged in nixpkgs
99 "test_basic"
100 "test_fts_native"
101
102 # polars.exceptions.ComputeError: TypeError: _scan_pyarrow_dataset_impl() got multiple values for argument 'batch_size'
103 # https://github.com/lancedb/lancedb/issues/1539
104 "test_polars"
105 ];
106
107 disabledTestPaths = [
108 # touch the network
109 "test_s3.py"
110 ]
111 ++ lib.optionals stdenv.hostPlatform.isDarwin [
112 # socket.gaierror: [Errno 8] nodename nor servname provided, or not known
113 "test_remote_db.py"
114 ];
115
116 passthru.updateScript = nix-update-script {
117 extraArgs = [
118 "--version-regex"
119 "python-v(.*)"
120 ];
121 };
122
123 meta = {
124 description = "Developer-friendly, serverless vector database for AI applications";
125 homepage = "https://github.com/lancedb/lancedb";
126 changelog = "https://github.com/lancedb/lancedb/releases/tag/python-v${version}";
127 license = lib.licenses.asl20;
128 maintainers = with lib.maintainers; [ natsukium ];
129 };
130}