nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 dask,
6 duckdb,
7 fetchFromGitHub,
8 hatchling,
9 hypothesis,
10 ibis-framework,
11 packaging,
12 pandas,
13 polars,
14 pyarrow-hotfix,
15 pyarrow,
16 pyspark,
17 pytest-env,
18 pytestCheckHook,
19 rich,
20 sqlframe,
21}:
22
23buildPythonPackage rec {
24 pname = "narwhals";
25 version = "2.15.0";
26 pyproject = true;
27
28 src = fetchFromGitHub {
29 owner = "narwhals-dev";
30 repo = "narwhals";
31 tag = "v${version}";
32 hash = "sha256-7tLxMtFWpk0ZpR9UYtKdk6L2UXb/ah1ZA6XZ4RbnvsI=";
33 };
34
35 build-system = [ hatchling ];
36
37 optional-dependencies = {
38 # cudf = [ cudf ];
39 dask = [ dask ] ++ dask.optional-dependencies.dataframe;
40 # modin = [ modin ];
41 pandas = [ pandas ];
42 polars = [ polars ];
43 pyarrow = [ pyarrow ];
44 pyspark = [ pyspark ];
45 ibis = [
46 ibis-framework
47 rich
48 packaging
49 pyarrow-hotfix
50 ];
51 sqlframe = [ sqlframe ];
52 };
53
54 nativeCheckInputs = [
55 duckdb
56 hypothesis
57 pytest-env
58 pytestCheckHook
59 ]
60 ++ lib.concatAttrValues optional-dependencies;
61
62 pythonImportsCheck = [ "narwhals" ];
63
64 disabledTests = [
65 # Flaky
66 "test_rolling_var_hypothesis"
67 # Missing file
68 "test_pyspark_connect_deps_2517"
69 # Timezone issue
70 "test_to_datetime"
71 "test_unary_two_elements"
72 # Test requires pyspark binary
73 "test_datetime_w_tz_pyspark"
74 "test_convert_time_zone_to_connection_tz_pyspark"
75 "test_replace_time_zone_to_connection_tz_pyspark"
76 "test_lazy"
77 # Incompatible with ibis 11
78 "test_unique_3069"
79 # DuckDB 1.4.x compatibility - empty result schema handling with PyArrow
80 "test_skew_expr"
81 # ibis improvements cause strict XPASS failures (tests expected to fail now pass)
82 "test_empty_scalar_reduction_with_columns"
83 "test_collect_empty"
84 ];
85
86 disabledTestPaths = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
87 # Segfault in included polars/lazyframe
88 "tests/tpch_q1_test.py"
89 ];
90
91 pytestFlags = [
92 "-Wignore::DeprecationWarning"
93 ];
94
95 meta = {
96 description = "Lightweight and extensible compatibility layer between dataframe libraries";
97 homepage = "https://github.com/narwhals-dev/narwhals";
98 changelog = "https://github.com/narwhals-dev/narwhals/releases/tag/${src.tag}";
99 license = lib.licenses.mit;
100 maintainers = with lib.maintainers; [ fab ];
101 };
102}