1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, python
6, beautifulsoup4
7, bottleneck
8, cython
9, python-dateutil
10, html5lib
11, jinja2
12, lxml
13, numexpr
14, openpyxl
15, pytz
16, scipy
17, sqlalchemy
18, tables
19, xlrd
20, xlwt
21# Test inputs
22, glibcLocales
23, hypothesis
24, pytestCheckHook
25, pytest-xdist
26, pytest-asyncio
27, XlsxWriter
28# Darwin inputs
29, runtimeShell
30, libcxx
31}:
32
33buildPythonPackage rec {
34 pname = "pandas";
35 version = "1.3.3";
36
37 src = fetchPypi {
38 inherit pname version;
39 sha256 = "272c8cb14aa9793eada6b1ebe81994616e647b5892a370c7135efb2924b701df";
40 };
41
42 nativeBuildInputs = [ cython ];
43
44 buildInputs = lib.optional stdenv.isDarwin libcxx;
45
46 propagatedBuildInputs = [
47 beautifulsoup4
48 bottleneck
49 python-dateutil
50 html5lib
51 numexpr
52 lxml
53 openpyxl
54 pytz
55 scipy
56 sqlalchemy
57 tables
58 xlrd
59 xlwt
60 ];
61
62 checkInputs = [
63 glibcLocales
64 hypothesis
65 jinja2
66 pytest-asyncio
67 pytest-xdist
68 pytestCheckHook
69 XlsxWriter
70 ];
71
72 # Doesn't work with -Werror,-Wunused-command-line-argument
73 # https://github.com/NixOS/nixpkgs/issues/39687
74 hardeningDisable = lib.optional stdenv.cc.isClang "strictoverflow";
75
76 # For OSX, we need to add a dependency on libcxx, which provides
77 # `complex.h` and other libraries that pandas depends on to build.
78 postPatch = lib.optionalString stdenv.isDarwin ''
79 cpp_sdk="${lib.getDev libcxx}/include/c++/v1";
80 echo "Adding $cpp_sdk to the setup.py common_include variable"
81 substituteInPlace setup.py \
82 --replace "['pandas/src/klib', 'pandas/src']" \
83 "['pandas/src/klib', 'pandas/src', '$cpp_sdk']"
84 '';
85
86 doCheck = !stdenv.isAarch64; # upstream doesn't test this architecture
87
88 pytestFlagsArray = [
89 "--skip-slow"
90 "--skip-network"
91 "--numprocesses" "0"
92 ];
93
94 disabledTests = [
95 # Locale-related
96 "test_names"
97 "test_dt_accessor_datetime_name_accessors"
98 "test_datetime_name_accessors"
99 # Disable IO related tests because IO data is no longer distributed
100 "io"
101 # Tries to import from pandas.tests post install
102 "util_in_top_level"
103 # Tries to import compiled C extension locally
104 "test_missing_required_dependency"
105 # AssertionError with 1.2.3
106 "test_from_coo"
107 # AssertionError: No common DType exists for the given inputs
108 "test_comparison_invalid"
109 ] ++ lib.optionals stdenv.isDarwin [
110 "test_locale"
111 "test_clipboard"
112 ];
113
114 # Tests have relative paths, and need to reference compiled C extensions
115 # so change directory where `import .test` is able to be resolved
116 preCheck = ''
117 cd $out/${python.sitePackages}/pandas
118 export LC_ALL="en_US.UTF-8"
119 PYTHONPATH=$out/${python.sitePackages}:$PYTHONPATH
120 ''
121 # TODO: Get locale and clipboard support working on darwin.
122 # Until then we disable the tests.
123 + lib.optionalString stdenv.isDarwin ''
124 # Fake the impure dependencies pbpaste and pbcopy
125 echo "#!${runtimeShell}" > pbcopy
126 echo "#!${runtimeShell}" > pbpaste
127 chmod a+x pbcopy pbpaste
128 export PATH=$(pwd):$PATH
129 '';
130
131 pythonImportsCheck = [ "pandas" ];
132
133 meta = with lib; {
134 # https://github.com/pandas-dev/pandas/issues/14866
135 # pandas devs are no longer testing i686 so safer to assume it's broken
136 broken = stdenv.isi686;
137 homepage = "https://pandas.pydata.org/";
138 changelog = "https://pandas.pydata.org/docs/whatsnew/index.html";
139 description = "Python Data Analysis Library";
140 license = licenses.bsd3;
141 maintainers = with maintainers; [ raskin fridh knedlsepp ];
142 platforms = platforms.unix;
143 };
144}