1{
2 lib,
3 buildPythonPackage,
4 dask,
5 duckdb,
6 fetchFromGitHub,
7 hatchling,
8 hypothesis,
9 ibis-framework,
10 packaging,
11 pandas,
12 polars,
13 pyarrow-hotfix,
14 pyarrow,
15 pyspark,
16 pytest-env,
17 pytestCheckHook,
18 rich,
19 sqlframe,
20}:
21
22buildPythonPackage rec {
23 pname = "narwhals";
24 version = "2.4.0";
25 pyproject = true;
26
27 src = fetchFromGitHub {
28 owner = "narwhals-dev";
29 repo = "narwhals";
30 tag = "v${version}";
31 hash = "sha256-ReF/6UNxxeQd4RspzmauEUJGaI1kY3hMPNYSDg8ZP2w=";
32 };
33
34 build-system = [ hatchling ];
35
36 optional-dependencies = {
37 # cudf = [ cudf ];
38 dask = [ dask ] ++ dask.optional-dependencies.dataframe;
39 # modin = [ modin ];
40 pandas = [ pandas ];
41 polars = [ polars ];
42 pyarrow = [ pyarrow ];
43 pyspark = [ pyspark ];
44 ibis = [
45 ibis-framework
46 rich
47 packaging
48 pyarrow-hotfix
49 ];
50 sqlframe = [ sqlframe ];
51 };
52
53 nativeCheckInputs = [
54 duckdb
55 hypothesis
56 pytest-env
57 pytestCheckHook
58 ]
59 ++ lib.flatten (builtins.attrValues optional-dependencies);
60
61 pythonImportsCheck = [ "narwhals" ];
62
63 disabledTests = [
64 # Flaky
65 "test_rolling_var_hypothesis"
66 # Missing file
67 "test_pyspark_connect_deps_2517"
68 # Timezone issue
69 "test_to_datetime"
70 "test_unary_two_elements"
71 # Test requires pyspark binary
72 "test_datetime_w_tz_pyspark"
73 "test_convert_time_zone_to_connection_tz_pyspark"
74 "test_replace_time_zone_to_connection_tz_pyspark"
75 "test_lazy"
76 ];
77
78 pytestFlags = [
79 "-Wignore::DeprecationWarning"
80 ];
81
82 meta = {
83 description = "Lightweight and extensible compatibility layer between dataframe libraries";
84 homepage = "https://github.com/narwhals-dev/narwhals";
85 changelog = "https://github.com/narwhals-dev/narwhals/releases/tag/${src.tag}";
86 license = lib.licenses.mit;
87 maintainers = with lib.maintainers; [ fab ];
88 };
89}