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