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