1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 rustPlatform,
7
8 # nativeBuildInputs
9 pkg-config,
10
11 # buildInputs
12 openssl,
13 protobuf,
14
15 # dependencies
16 numpy,
17 pyarrow,
18
19 # optional-dependencies
20 torch,
21
22 # tests
23 duckdb,
24 ml-dtypes,
25 pandas,
26 pillow,
27 polars,
28 pytestCheckHook,
29 tqdm,
30}:
31
32buildPythonPackage rec {
33 pname = "pylance";
34 version = "0.26.1";
35 pyproject = true;
36
37 src = fetchFromGitHub {
38 owner = "lancedb";
39 repo = "lance";
40 tag = "v${version}";
41 hash = "sha256-peTfrSDByfqg3jiSK8FZr7m+/Mu/mCqeZhR/902Qp4s=";
42 };
43
44 sourceRoot = "${src.name}/python";
45
46 cargoDeps = rustPlatform.fetchCargoVendor {
47 inherit
48 pname
49 version
50 src
51 sourceRoot
52 ;
53 hash = "sha256-UZ2a7bhK+rJ2jMw9hqyfHjfGRrmG/eB7thjkfguU11o=";
54 };
55
56 nativeBuildInputs = [
57 pkg-config
58 protobuf # for protoc
59 rustPlatform.cargoSetupHook
60 ];
61
62 build-system = [
63 rustPlatform.cargoSetupHook
64 rustPlatform.maturinBuildHook
65 ];
66
67 buildInputs = [
68 openssl
69 protobuf
70 ];
71
72 pythonRelaxDeps = [ "pyarrow" ];
73
74 dependencies = [
75 numpy
76 pyarrow
77 ];
78
79 optional-dependencies = {
80 torch = [ torch ];
81 };
82
83 pythonImportsCheck = [ "lance" ];
84
85 nativeCheckInputs = [
86 duckdb
87 ml-dtypes
88 pandas
89 pillow
90 polars
91 pytestCheckHook
92 tqdm
93 ] ++ optional-dependencies.torch;
94
95 preCheck = ''
96 cd python/tests
97 '';
98
99 disabledTests =
100 [
101 # Writes to read-only build directory
102 "test_add_data_storage_version"
103 "test_fix_data_storage_version"
104 ]
105 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
106 # OSError: LanceError(IO): Resources exhausted: Failed to allocate additional 1245184 bytes for ExternalSorter[0]...
107 "test_merge_insert_large"
108 ];
109
110 meta = {
111 description = "Python wrapper for Lance columnar format";
112 homepage = "https://github.com/lancedb/lance";
113 changelog = "https://github.com/lancedb/lance/releases/tag/v${version}";
114 license = lib.licenses.asl20;
115 maintainers = with lib.maintainers; [ natsukium ];
116 };
117}