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