1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, python
6, pythonOlder
7, cython
8, numpy
9, python-dateutil
10, pytz
11, scipy
12, sqlalchemy
13, tables
14, xlrd
15, xlwt
16# Test inputs
17, glibcLocales
18, hypothesis
19, jinja2
20, pytestCheckHook
21, pytest-xdist
22, pytest-asyncio
23, XlsxWriter
24# Darwin inputs
25, runtimeShell
26, libcxx
27}:
28
29buildPythonPackage rec {
30 pname = "pandas";
31 version = "1.4.4";
32 format = "setuptools";
33 disabled = pythonOlder "3.8";
34
35 src = fetchPypi {
36 inherit pname version;
37 hash = "sha256-q2wNc4YXtnUYPl8o2zK1FItpStm7oKQMPqJtlrQx22c=";
38 };
39
40 nativeBuildInputs = [ cython ];
41
42 buildInputs = lib.optional stdenv.isDarwin libcxx;
43
44 propagatedBuildInputs = [
45 numpy
46 python-dateutil
47 pytz
48 ];
49
50 checkInputs = [
51 glibcLocales
52 hypothesis
53 jinja2
54 pytest-asyncio
55 pytest-xdist
56 pytestCheckHook
57 XlsxWriter
58 ];
59
60 # Doesn't work with -Werror,-Wunused-command-line-argument
61 # https://github.com/NixOS/nixpkgs/issues/39687
62 hardeningDisable = lib.optional stdenv.cc.isClang "strictoverflow";
63
64 doCheck = !stdenv.isAarch32 && !stdenv.isAarch64; # upstream doesn't test this architecture
65
66 # don't max out build cores, it breaks tests
67 dontUsePytestXdist = true;
68
69 pytestFlagsArray = [
70 # https://github.com/pandas-dev/pandas/blob/main/test_fast.sh
71 "--skip-db"
72 "--skip-slow"
73 "--skip-network"
74 "-m" "'not single_cpu'"
75 "--numprocesses" "4"
76 ];
77
78 disabledTests = [
79 # Locale-related
80 "test_names"
81 "test_dt_accessor_datetime_name_accessors"
82 "test_datetime_name_accessors"
83 # Disable IO related tests because IO data is no longer distributed
84 "io"
85 # Tries to import from pandas.tests post install
86 "util_in_top_level"
87 # Tries to import compiled C extension locally
88 "test_missing_required_dependency"
89 # AssertionError with 1.2.3
90 "test_from_coo"
91 # AssertionError: No common DType exists for the given inputs
92 "test_comparison_invalid"
93 # AssertionError: Regex pattern '"quotechar" must be string, not int'
94 "python-kwargs2"
95 # Tests for rounding errors and fails if we have better precision
96 # than expected, e.g. on amd64 with FMA or on arm64
97 # https://github.com/pandas-dev/pandas/issues/38921
98 "test_rolling_var_numerical_issues"
99 ] ++ lib.optionals stdenv.isDarwin [
100 "test_locale"
101 "test_clipboard"
102 # ValueError: cannot reindex on an axis with duplicate labels
103 #
104 # Attempts to reproduce this problem outside of Hydra failed.
105 "test_reindex_timestamp_with_fold"
106 ];
107
108 # Tests have relative paths, and need to reference compiled C extensions
109 # so change directory where `import .test` is able to be resolved
110 preCheck = ''
111 cd $out/${python.sitePackages}/pandas
112 export LC_ALL="en_US.UTF-8"
113 PYTHONPATH=$out/${python.sitePackages}:$PYTHONPATH
114 ''
115 # TODO: Get locale and clipboard support working on darwin.
116 # Until then we disable the tests.
117 + lib.optionalString stdenv.isDarwin ''
118 # Fake the impure dependencies pbpaste and pbcopy
119 echo "#!${runtimeShell}" > pbcopy
120 echo "#!${runtimeShell}" > pbpaste
121 chmod a+x pbcopy pbpaste
122 export PATH=$(pwd):$PATH
123 '';
124
125 enableParallelBuilding = true;
126
127 pythonImportsCheck = [ "pandas" ];
128
129 meta = with lib; {
130 # https://github.com/pandas-dev/pandas/issues/14866
131 # pandas devs are no longer testing i686 so safer to assume it's broken
132 broken = stdenv.isi686;
133 homepage = "https://pandas.pydata.org/";
134 changelog = "https://pandas.pydata.org/docs/whatsnew/index.html";
135 description = "Python Data Analysis Library";
136 license = licenses.bsd3;
137 maintainers = with maintainers; [ raskin fridh knedlsepp ];
138 platforms = platforms.unix;
139 };
140}