1{
2 stdenv,
3 lib,
4 buildPythonPackage,
5 fetchPypi,
6 isPyPy,
7 R,
8 libdeflate,
9 rWrapper,
10 rPackages,
11 pcre,
12 xz,
13 bzip2,
14 zlib,
15 icu,
16 ipython,
17 jinja2,
18 pytz,
19 pandas,
20 numpy,
21 cffi,
22 tzlocal,
23 simplegeneric,
24 pytestCheckHook,
25 extraRPackages ? [ ],
26}:
27
28buildPythonPackage rec {
29 version = "3.5.16";
30 format = "setuptools";
31 pname = "rpy2";
32
33 disabled = isPyPy;
34 src = fetchPypi {
35 inherit version pname;
36 hash = "sha256-g34vdFg2WKXEwzl2GnP5Q08z75ztPjDGTadWIWXCgBs=";
37 };
38
39 patches = [
40 # R_LIBS_SITE is used by the nix r package to point to the installed R libraries.
41 # This patch sets R_LIBS_SITE when rpy2 is imported.
42 ./rpy2-3.x-r-libs-site.patch
43 ];
44
45 postPatch = ''
46 substituteInPlace 'rpy2/rinterface_lib/embedded.py' --replace '@NIX_R_LIBS_SITE@' "$R_LIBS_SITE"
47 substituteInPlace 'requirements.txt' --replace 'pytest' ""
48 '';
49
50 buildInputs =
51 [
52 pcre
53 xz
54 bzip2
55 zlib
56 icu
57 libdeflate
58 ]
59 ++ (with rPackages; [
60 # packages expected by the test framework
61 ggplot2
62 dplyr
63 RSQLite
64 broom
65 DBI
66 dbplyr
67 hexbin
68 lazyeval
69 lme4
70 tidyr
71 ])
72 ++ extraRPackages
73 ++ rWrapper.recommendedPackages;
74
75 nativeBuildInputs = [
76 R # needed at setup time to detect R_HOME (alternatively set R_HOME explicitly)
77 ];
78
79 propagatedBuildInputs = [
80 ipython
81 jinja2
82 pytz
83 pandas
84 numpy
85 cffi
86 tzlocal
87 simplegeneric
88 ];
89
90 doCheck = !stdenv.isDarwin;
91
92 # https://github.com/rpy2/rpy2/issues/1111
93 disabledTests = [
94 "test_parse_incomplete_error"
95 "test_parse_error"
96 "test_parse_error_when_evaluting"
97 ];
98
99 nativeCheckInputs = [ pytestCheckHook ];
100
101 meta = {
102 homepage = "https://rpy2.github.io/";
103 description = "Python interface to R";
104 license = lib.licenses.gpl2Plus;
105 platforms = lib.platforms.unix;
106 maintainers = with lib.maintainers; [ joelmo ];
107 };
108}