Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 19.03 2.6 kB view raw
1{ lib 2, python 3, buildPythonPackage 4, fetchPypi 5, isPyPy 6, isPy27 7, readline 8, R 9, rWrapper 10, rPackages 11, pcre 12, lzma 13, bzip2 14, zlib 15, icu 16, singledispatch 17, six 18, jinja2 19, pytz 20, numpy 21, pytest 22, mock 23, extraRPackages ? [] 24}: 25 26buildPythonPackage rec { 27 version = if isPy27 then 28 "2.8.6" # python2 support dropped in 2.9.x 29 else 30 "2.9.5"; 31 pname = "rpy2"; 32 disabled = isPyPy; 33 src = fetchPypi { 34 inherit version pname; 35 sha256 = if isPy27 then 36 "162zki5c1apgv6qbafi7n66y4hgpgp43xag7q75qb6kv99ri6k80" # 2.8.x 37 else 38 "1nrj8pgyxrwrfdrxzb4j3z1adjwjx1mr8d1n5cmrz4nhlzy8w7xr"; # 2.9.x 39 }; 40 buildInputs = [ 41 readline 42 R 43 pcre 44 lzma 45 bzip2 46 zlib 47 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 nativeBuildInputs = [ 62 R # needed at setup time to detect R_HOME (alternatively set R_HOME explicitly) 63 ]; 64 65 patches = [ 66 # R_LIBS_SITE is used by the nix r package to point to the installed R libraries. 67 # This patch sets R_LIBS_SITE when rpy2 is imported. 68 ./r-libs-site.patch 69 ]; 70 postPatch = '' 71 substituteInPlace rpy/rinterface/__init__.py --replace '@NIX_R_LIBS_SITE@' "$R_LIBS_SITE" 72 ''; 73 74 propagatedBuildInputs = [ 75 singledispatch 76 six 77 jinja2 78 pytz 79 numpy 80 ]; 81 82 checkInputs = [ 83 pytest 84 mock 85 ]; 86 # One remaining test failure caused by different unicode encoding. 87 # https://bitbucket.org/rpy2/rpy2/issues/488 88 doCheck = false; 89 checkPhase = '' 90 ${python.interpreter} -m 'rpy2.tests' 91 ''; 92 93 # For some reason libreadline.so is not found. Curiously `ldd _rinterface.so | grep readline` shows two readline entries: 94 # libreadline.so.6 => not found 95 # libreadline.so.6 => /nix/store/z2zhmrg6jcrn5iq2779mav0nnq4vm2q6-readline-6.3p08/lib/libreadline.so.6 (0x00007f333ac43000) 96 # There must be a better way to fix this, but I don't know it. 97 postFixup = '' 98 patchelf --add-needed ${readline}/lib/libreadline.so "$out/${python.sitePackages}/rpy2/rinterface/"_rinterface*.so 99 ''; 100 101 meta = { 102 homepage = http://rpy.sourceforge.net/rpy2; 103 description = "Python interface to R"; 104 license = lib.licenses.gpl2Plus; 105 platforms = lib.platforms.unix; 106 maintainers = with lib.maintainers; [ joelmo ]; 107 }; 108 }