diff --git a/user/py3-rpy2/APKBUILD b/user/py3-rpy2/APKBUILD new file mode 100644 index 0000000..1a5e83c --- /dev/null +++ b/user/py3-rpy2/APKBUILD @@ -0,0 +1,34 @@ +# Maintainer: Antoine Martin (ayakael) +# Contributor: Antoine Martin (ayakael) + +pkgname=py3-rpy2 +_pyname="rpy2" +pkgver=3.5.11 +pkgrel=0 +arch="all" +pkgdesc="A very simple, yet robust, Python interface to the R Programming Language" +url="https://pypi.python.org/project/$_pyname" +license="GPL-2.0" +depends='python3-dev py3-cffi py3-numpy py3-tz py3-tzlocal py3-jinja2 R' +makedepends='py3-build py3-installer py3-setuptools py3-wheel' +checkdepends='py3-pytest' +options="!check" # test failure +source="$pkgname-$pkgver.tar.gz::https://pypi.io/packages/source/${_pyname:0:1}/$_pyname/$_pyname-$pkgver.tar.gz" +builddir="$srcdir"/$_pyname-$pkgver + +build() { + python3 -m build --wheel --no-isolation +} + +check() { + PYTHONPATH="$PWD"/$(echo build/lib.*) \ + pytest -v -k 'not test_rendertofile and not test_rendertobytes_plot' # Skip test that segfaults in build server +} + +package() { + python3 -m installer --destdir="$pkgdir" dist/*.whl +} + +sha512sums=" +c0becf26f19c9f9e34033bde12bc34f1322cbc7ca215e1081b27689a62d6c9a012ab4478e4c867e510d519bc475c2b27ee93f43a0b513dd3f2c0bea2389b9862 py3-rpy2-3.5.11.tar.gz +" diff --git a/user/py3-rpy2/set_ld_library_path_before_initializing_r.patch b/user/py3-rpy2/set_ld_library_path_before_initializing_r.patch new file mode 100644 index 0000000..4523db3 --- /dev/null +++ b/user/py3-rpy2/set_ld_library_path_before_initializing_r.patch @@ -0,0 +1,55 @@ +From c8a0c67b1c4da9054e542714a43fef12ecbc4222 Mon Sep 17 00:00:00 2001 +From: Laurent Gautier +Date: Sun, 5 Dec 2021 21:31:23 -0500 +Subject: [PATCH] Set LD_LIBRARY_PATH before initializing R. + +(issue #833). +--- + NEWS | 3 +++ + rpy2/rinterface_lib/embedded.py | 6 ++++++ + rpy2/rinterface_lib/openrlib.py | 1 + + 3 files changed, 10 insertions(+) + +diff --git a/NEWS b/NEWS +index cf15215c..aac6ae2c 100644 +--- a/NEWS ++++ b/NEWS +@@ -33,6 +33,9 @@ Changes + - :obj:`rpy2.rinterface.NULL` can be refererenced in code before the embedded + R is initialized. + ++- `LD_LIBRARY_PATH` is obtained from the executable `RScript` and set prior ++ to initializing R at the rinterface level (issue #833). ++ + Bugs fixed + ---------- + +diff --git a/rpy2/rinterface_lib/embedded.py b/rpy2/rinterface_lib/embedded.py +index 8d2ad651..978630ec 100644 +--- a/rpy2/rinterface_lib/embedded.py ++++ b/rpy2/rinterface_lib/embedded.py +@@ -255,6 +255,12 @@ def _initr( + _setinitialized() + return None + os.environ['R_HOME'] = openrlib.R_HOME ++ os.environ['LD_LIBRARY_PATH'] = ( ++ ':'.join( ++ (openrlib.LD_LIBRARY_PATH, ++ os.environ.get('LD_LIBRARY_PATH', '')) ++ ) ++ ) + options_c = [ffi.new('char[]', o.encode('ASCII')) for o in _options] + n_options = len(options_c) + n_options_c = ffi.cast('int', n_options) +diff --git a/rpy2/rinterface_lib/openrlib.py b/rpy2/rinterface_lib/openrlib.py +index 9254fa73..2e183481 100644 +--- a/rpy2/rinterface_lib/openrlib.py ++++ b/rpy2/rinterface_lib/openrlib.py +@@ -20,6 +20,7 @@ + # TODO: Separate the functions in the module from the side-effect of + # finding R_HOME and opening the shared library. + R_HOME = rpy2.situation.get_r_home() ++LD_LIBRARY_PATH = rpy2.situation.r_ld_library_path_from_subprocess(R_HOME) + rlock = threading.RLock() + +