1# Python 2 expression
2
3{ lib
4, buildPythonPackage
5, fetchPypi
6, python
7, stdenv
8, pytest
9, glibcLocales
10, cython
11, python-dateutil
12, scipy
13, moto
14, numexpr
15, pytz
16, xlrd
17, bottleneck
18, sqlalchemy
19, lxml
20, html5lib
21, beautifulsoup4
22, hypothesis
23, openpyxl
24, tables
25, xlwt
26, runtimeShell
27, libcxx ? null
28}:
29
30buildPythonPackage rec {
31 pname = "pandas";
32 version = "0.24.2";
33
34 src = fetchPypi {
35 inherit pname version;
36 sha256 = "18imlm8xbhcbwy4wa957a1fkamrcb0z988z006jpfda3ki09z4ag";
37 };
38
39 checkInputs = [ pytest glibcLocales moto hypothesis ];
40
41 nativeBuildInputs = [ cython ];
42 buildInputs = lib.optional stdenv.isDarwin libcxx;
43 propagatedBuildInputs = [
44 python-dateutil
45 scipy
46 numexpr
47 pytz
48 xlrd
49 bottleneck
50 sqlalchemy
51 lxml
52 html5lib
53 beautifulsoup4
54 openpyxl
55 tables
56 xlwt
57 ];
58
59 # For OSX, we need to add a dependency on libcxx, which provides
60 # `complex.h` and other libraries that pandas depends on to build.
61 postPatch = lib.optionalString stdenv.isDarwin ''
62 cpp_sdk="${lib.getDev libcxx}/include/c++/v1";
63 echo "Adding $cpp_sdk to the setup.py common_include variable"
64 substituteInPlace setup.py \
65 --replace "['pandas/src/klib', 'pandas/src']" \
66 "['pandas/src/klib', 'pandas/src', '$cpp_sdk']"
67 '';
68
69
70 disabledTests = lib.concatMapStringsSep " and " (s: "not " + s) ([
71 # since python-dateutil 0.6.0 the following fails: test_fallback_plural, test_ambiguous_flags, test_ambiguous_compat
72 # was supposed to be solved by https://github.com/dateutil/dateutil/issues/321, but is not the case
73 "test_fallback_plural"
74 "test_ambiguous_flags"
75 "test_ambiguous_compat"
76 # Locale-related
77 "test_names"
78 "test_dt_accessor_datetime_name_accessors"
79 "test_datetime_name_accessors"
80 # Can't import from test folder
81 "test_oo_optimizable"
82 # Disable IO related tests because IO data is no longer distributed
83 "io"
84 # KeyError Timestamp
85 "test_to_excel"
86 ] ++ lib.optionals stdenv.isDarwin [
87 "test_locale"
88 "test_clipboard"
89 ]);
90
91 doCheck = !stdenv.isAarch64; # upstream doesn't test this architecture
92
93 checkPhase = ''
94 runHook preCheck
95 ''
96 # TODO: Get locale and clipboard support working on darwin.
97 # Until then we disable the tests.
98 + lib.optionalString stdenv.isDarwin ''
99 # Fake the impure dependencies pbpaste and pbcopy
100 echo "#!${runtimeShell}" > pbcopy
101 echo "#!${runtimeShell}" > pbpaste
102 chmod a+x pbcopy pbpaste
103 export PATH=$(pwd):$PATH
104 '' + ''
105 LC_ALL="en_US.UTF-8" py.test $out/${python.sitePackages}/pandas --skip-slow --skip-network -k "$disabledTests"
106 runHook postCheck
107 '';
108
109 meta = with lib; {
110 # https://github.com/pandas-dev/pandas/issues/14866
111 # pandas devs are no longer testing i686 so safer to assume it's broken
112 broken = stdenv.isi686;
113 homepage = "https://pandas.pydata.org/";
114 description = "Python Data Analysis Library";
115 license = licenses.bsd3;
116 maintainers = with maintainers; [ raskin knedlsepp ];
117 platforms = platforms.unix;
118 };
119}