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