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