1{ lib
2, python
3, buildPythonPackage
4, fetchpatch
5, fetchPypi
6, isPyPy
7, R
8, rWrapper
9, rPackages
10, pcre
11, lzma
12, bzip2
13, zlib
14, icu
15, ipython
16, jinja2
17, pytz
18, pandas
19, numpy
20, cffi
21, tzlocal
22, simplegeneric
23, pytest
24, extraRPackages ? []
25}:
26
27buildPythonPackage rec {
28 version = "3.2.6";
29 pname = "rpy2";
30
31 disabled = isPyPy;
32 src = fetchPypi {
33 inherit version pname;
34 sha256 = "1p990cqx3p2pd1rc9wn66m56wahaq8dlr88frz49vb7nv4zw4a8q";
35 };
36
37 buildInputs = [
38 R
39 pcre
40 lzma
41 bzip2
42 zlib
43 icu
44
45 # is in the upstream `requires` although it shouldn't be -- this is easier than patching it away
46 pytest
47 ] ++ (with rPackages; [
48 # packages expected by the test framework
49 ggplot2
50 dplyr
51 RSQLite
52 broom
53 DBI
54 dbplyr
55 hexbin
56 lme4
57 tidyr
58 ]) ++ extraRPackages ++ rWrapper.recommendedPackages;
59
60 checkPhase = ''
61 pytest
62 '';
63
64 nativeBuildInputs = [
65 R # needed at setup time to detect R_HOME (alternatively set R_HOME explicitly)
66 ];
67
68 patches = [
69 # R_LIBS_SITE is used by the nix r package to point to the installed R libraries.
70 # This patch sets R_LIBS_SITE when rpy2 is imported.
71 ./rpy2-3.x-r-libs-site.patch
72
73 # pandas 1.x compatibility, already merged upstream
74 # https://github.com/rpy2/rpy2/issues/636
75 (fetchpatch {
76 name = "pandas-1.x.patch";
77 url = "https://github.com/rpy2/rpy2/commit/fbd060e364b70012e8d26cc74df04ee53f769379.patch";
78 sha256 = "19rdqydwjmqg25ibmsbx7lggrr9fsyjn283zgvz1wj4iyfjwp1za";
79 })
80 ];
81 postPatch = ''
82 substituteInPlace 'rpy2/rinterface_lib/embedded.py' --replace '@NIX_R_LIBS_SITE@' "$R_LIBS_SITE"
83 '';
84
85 propagatedBuildInputs = [
86 ipython
87 jinja2
88 pytz
89 pandas
90 numpy
91 cffi
92 tzlocal
93 simplegeneric
94 ];
95
96 checkInputs = [
97 pytest
98 ];
99
100 meta = {
101 broken = true;
102 homepage = "http://rpy.sourceforge.net/rpy2";
103 description = "Python interface to R";
104 license = lib.licenses.gpl2Plus;
105 platforms = lib.platforms.unix;
106 maintainers = with lib.maintainers; [ joelmo ];
107 };
108 }