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