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 datafusion,
24 duckdb,
25 ml-dtypes,
26 pandas,
27 pillow,
28 polars,
29 pytestCheckHook,
30 tqdm,
31}:
32
33buildPythonPackage rec {
34 pname = "pylance";
35 version = "0.27.2";
36 pyproject = true;
37
38 src = fetchFromGitHub {
39 owner = "lancedb";
40 repo = "lance";
41 tag = "v${version}";
42 hash = "sha256-fk32CnWH9wVKfTgT2Es6+tnvB+rPzkA8in0J726JHx0=";
43 };
44
45 sourceRoot = "${src.name}/python";
46
47 cargoDeps = rustPlatform.fetchCargoVendor {
48 inherit
49 pname
50 version
51 src
52 sourceRoot
53 ;
54 hash = "sha256-N7ODbv+q9xX8lb4vvUzMGTul/whNw+dVrBp/YcEaREI=";
55 };
56
57 nativeBuildInputs = [
58 pkg-config
59 protobuf # for protoc
60 rustPlatform.cargoSetupHook
61 ];
62
63 build-system = [
64 rustPlatform.cargoSetupHook
65 rustPlatform.maturinBuildHook
66 ];
67
68 buildInputs = [
69 openssl
70 protobuf
71 ];
72
73 pythonRelaxDeps = [ "pyarrow" ];
74
75 dependencies = [
76 numpy
77 pyarrow
78 ];
79
80 optional-dependencies = {
81 torch = [ torch ];
82 };
83
84 pythonImportsCheck = [ "lance" ];
85
86 nativeCheckInputs = [
87 datafusion
88 duckdb
89 ml-dtypes
90 pandas
91 pillow
92 polars
93 pytestCheckHook
94 tqdm
95 ] ++ optional-dependencies.torch;
96
97 preCheck = ''
98 cd python/tests
99 '';
100
101 disabledTests =
102 [
103 # Writes to read-only build directory
104 "test_add_data_storage_version"
105 "test_fix_data_storage_version"
106
107 # AttributeError: 'SessionContext' object has no attribute 'register_table_provider'
108 "test_table_loading"
109
110 # subprocess.CalledProcessError: Command ... returned non-zero exit status 1.
111 # ModuleNotFoundError: No module named 'lance'
112 "test_tracing"
113 ]
114 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
115 # OSError: LanceError(IO): Resources exhausted: Failed to allocate additional 1245184 bytes for ExternalSorter[0]...
116 "test_merge_insert_large"
117 ];
118
119 meta = {
120 description = "Python wrapper for Lance columnar format";
121 homepage = "https://github.com/lancedb/lance";
122 changelog = "https://github.com/lancedb/lance/releases/tag/v${version}";
123 license = lib.licenses.asl20;
124 maintainers = with lib.maintainers; [ natsukium ];
125 };
126}