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