git.iko.soy/typeable/nixpkgs
on master help sign in
pythonPackages.rpy2: various fixes (#51084)

- make sure libreadline is found at runtime - make sure python libraries are found at runtime - add libraries necessary to pass the testsuite and standard libraries

commit63b39af496505034fd5125f9a94dccd795d1b648 authorTimo Kaufmann <timokau@zoho.com> dateTue 27 Nov 2018, 18:24 (8 years ago) parentbe8569b
3 files changed+71−5
pkgs/development/python-modules/rpy2/default.nix+48−5 pkgs/development/python-modules/rpy2/r-libs-site.patch+20 pkgs/development/r-modules/wrapper.nix+3
pkgs/development/python-modules/rpy2/default.nix+48−5
@@ -1,10 +1,13 @@
11{ lib
2+, python
23, buildPythonPackage
34, fetchPypi
45, isPyPy
56, isPy27
67, readline
78, R
9+, rWrapper
10+, rPackages
811, pcre
912, lzma
1013, bzip2
@@ -13,7 +16,11 @@
1316, singledispatch
1417, six
1518, jinja2
19+, pytz
20+, numpy
1621, pytest
22+, mock
23+, extraRPackages ? []
1724}:
1825
1926buildPythonPackage rec {
@@ -38,18 +45,54 @@ buildPythonPackage rec {
3845 bzip2
3946 zlib
4047 icu
48+ ] ++ (with rPackages; [
49+ # packages expected by the test framework
50+ ggplot2
51+ dplyr
52+ RSQLite
53+ broom
54+ DBI
55+ dbplyr
56+ hexbin
57+ lme4
58+ tidyr
59+ ]) ++ extraRPackages ++ rWrapper.recommendedPackages;
60+
61+ patches = [
62+ # R_LIBS_SITE is used by the nix r package to point to the installed R libraries.
63+ # This patch sets R_LIBS_SITE when rpy2 is imported.
64+ ./r-libs-site.patch
4165 ];
66+ postPatch = ''
67+ substituteInPlace rpy/rinterface/__init__.py --replace '@NIX_R_LIBS_SITE@' "$R_LIBS_SITE"
68+ '';
69+
4270 propagatedBuildInputs = [
4371 singledispatch
4472 six
4573 jinja2
74+ pytz
75+ numpy
4676 ];
47− checkInputs = [ pytest ];
48− # Tests fail with `assert not _relpath.startswith('..'), "Path must be within the project"`
49− # in the unittest `loader.py`. I don't know what causes this.
77+
78+ checkInputs = [
79+ pytest
80+ mock
81+ ];
82+ # One remaining test failure caused by different unicode encoding.
83+ # https://bitbucket.org/rpy2/rpy2/issues/488
5084 doCheck = false;
51− # without this tests fail when looking for libreadline.so
52− LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
85+ checkPhase = ''
86+ ${python.interpreter} -m 'rpy2.tests'
87+ '';
88+
89+ # For some reason libreadline.so is not found. Curiously `ldd _rinterface.so | grep readline` shows two readline entries:
90+ # libreadline.so.6 => not found
91+ # libreadline.so.6 => /nix/store/z2zhmrg6jcrn5iq2779mav0nnq4vm2q6-readline-6.3p08/lib/libreadline.so.6 (0x00007f333ac43000)
92+ # There must be a better way to fix this, but I don't know it.
93+ postFixup = ''
94+ patchelf --add-needed ${readline}/lib/libreadline.so "$out/${python.sitePackages}/rpy2/rinterface/"_rinterface*.so
95+ '';
5396
5497 meta = {
5598 homepage = http://rpy.sourceforge.net/rpy2;
pkgs/development/python-modules/rpy2/r-libs-site.patchnew file+20
@@ -0,0 +1,20 @@
1+diff --git a/rpy/rinterface/__init__.py b/rpy/rinterface/__init__.py
2+index 9362e57..1af258e 100644
3+--- a/rpy/rinterface/__init__.py
4++++ b/rpy/rinterface/__init__.py
5+@@ -43,6 +43,15 @@ if not R_HOME:
6+ if not os.environ.get("R_HOME"):
7+ os.environ['R_HOME'] = R_HOME
8+
9++# path to libraries
10++existing = os.environ.get('R_LIBS_SITE')
11++if existing is not None:
12++ prefix = existing + ':'
13++else:
14++ prefix = ''
15++additional = '@NIX_R_LIBS_SITE@'
16++os.environ['R_LIBS_SITE'] = prefix + additional
17++
18+ if sys.platform == 'win32':
19+ _load_r_dll(R_HOME)
20+
pkgs/development/r-modules/wrapper.nix+3
@@ -5,6 +5,9 @@ stdenv.mkDerivation {
55
66 buildInputs = [makeWrapper R] ++ recommendedPackages ++ packages;
77
8+ # Make the list of recommended R packages accessible to other packages such as rpy2
9+ passthru.recommendedPackages = recommendedPackages;
10+
811 unpackPhase = ":";
912
1013 installPhase = ''