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 [
53 pcre
54 xz
55 bzip2
56 zlib
57 zstd
58 icu
59 libdeflate
60 ]
61 ++ (with rPackages; [
62 # packages expected by the test framework
63 ggplot2
64 dplyr
65 RSQLite
66 broom
67 DBI
68 dbplyr
69 hexbin
70 lazyeval
71 lme4
72 tidyr
73 ])
74 ++ extraRPackages
75 ++ rWrapper.recommendedPackages;
76
77 nativeBuildInputs = [
78 R # needed at setup time to detect R_HOME (alternatively set R_HOME explicitly)
79 ];
80
81 propagatedBuildInputs = [
82 ipython
83 jinja2
84 pytz
85 pandas
86 numpy
87 cffi
88 tzlocal
89 simplegeneric
90 ];
91
92 doCheck = !stdenv.hostPlatform.isDarwin;
93
94 # https://github.com/rpy2/rpy2/issues/1111
95 disabledTests = [
96 "test_parse_incomplete_error"
97 "test_parse_error"
98 "test_parse_error_when_evaluting"
99 ];
100
101 nativeCheckInputs = [ pytestCheckHook ];
102
103 meta = {
104 homepage = "https://rpy2.github.io/";
105 description = "Python interface to R";
106 license = lib.licenses.gpl2Plus;
107 platforms = lib.platforms.unix;
108 maintainers = with lib.maintainers; [ joelmo ];
109 };
110}