mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 02:40:31 +08:00
sage, python313Packages.rpy2: unbreak (#441027)
This commit is contained in:
@@ -82,6 +82,20 @@ stdenv.mkDerivation rec {
|
||||
url = "https://github.com/sagemath/sage/commit/d0cbe9d353722580f98a327694f1a361c9b83ccd.patch?full_index=1";
|
||||
hash = "sha256-uV2nttxCKDsNqMf1O+lUmuoiDrx7/CfiS00JBb9kiM8=";
|
||||
})
|
||||
|
||||
# https://github.com/sagemath/sage/pull/40156, landed in 10.7.beta5
|
||||
(fetchpatch2 {
|
||||
name = "cython-3.1-update.patch";
|
||||
url = "https://github.com/sagemath/sage/commit/5ea8db28977ec113aec3c4c4b208d1783e3937a7.patch?full_index=1";
|
||||
hash = "sha256-5DPPxMuidPpVHrjK8j0UVZzuwiVy9vQzFd6hBYwNAok=";
|
||||
})
|
||||
|
||||
# https://github.com/sagemath/sage/pull/40175, landed in 10.7.beta8
|
||||
(fetchpatch2 {
|
||||
name = "rpy2-3.6-update.patch";
|
||||
url = "https://github.com/sagemath/sage/commit/db2d8db99d9a7dfa1972d534ecd89e3d2ba5c55b.patch?full_index=1";
|
||||
hash = "sha256-6Bk0uGlKFsiDsgv+ljMC1YnmAT+g+he6aFNkpvw2on0=";
|
||||
})
|
||||
];
|
||||
|
||||
patches = nixPatches ++ bugfixPatches ++ packageUpgradePatches;
|
||||
|
||||
79
pkgs/development/python-modules/rpy2-rinterface/default.nix
Normal file
79
pkgs/development/python-modules/rpy2-rinterface/default.nix
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
buildPythonPackage,
|
||||
fetchurl,
|
||||
isPyPy,
|
||||
R,
|
||||
rWrapper,
|
||||
xz,
|
||||
bzip2,
|
||||
zlib,
|
||||
zstd,
|
||||
icu,
|
||||
pytestCheckHook,
|
||||
setuptools,
|
||||
cffi,
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
version = "3.6.3";
|
||||
format = "pyproject";
|
||||
pname = "rpy2-rinterface";
|
||||
|
||||
disabled = isPyPy;
|
||||
src = fetchurl {
|
||||
url = "mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${
|
||||
builtins.replaceStrings [ "-" ] [ "_" ] pname
|
||||
}-${version}.tar.gz";
|
||||
hash = "sha256-R3vC9R0AetG4VnxdS6GvD1mVFobufxBXagbQg03ld28=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# https://github.com/rpy2/rpy2/pull/1171#issuecomment-3263994962
|
||||
./restore-initr-simple.patch
|
||||
|
||||
# R_LIBS_SITE is used by the nix r package to point to the installed R libraries.
|
||||
# This patch sets R_LIBS_SITE when rpy2 is imported.
|
||||
./rpy2-3.x-r-libs-site.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace 'src/rpy2/rinterface_lib/embedded.py' --replace '@NIX_R_LIBS_SITE@' "$R_LIBS_SITE"
|
||||
'';
|
||||
|
||||
buildInputs = [
|
||||
xz
|
||||
bzip2
|
||||
zlib
|
||||
zstd
|
||||
icu
|
||||
]
|
||||
++ rWrapper.recommendedPackages;
|
||||
|
||||
nativeBuildInputs = [
|
||||
R # needed at setup time to detect R_HOME (alternatively set R_HOME explicitly)
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
cffi
|
||||
setuptools
|
||||
];
|
||||
|
||||
nativeCheckInputs = [ pytestCheckHook ];
|
||||
|
||||
# https://github.com/rpy2/rpy2/issues/1111
|
||||
disabledTests = [
|
||||
"test_parse_incomplete_error"
|
||||
"test_parse_error"
|
||||
"test_parse_error_when_evaluting"
|
||||
];
|
||||
|
||||
meta = {
|
||||
homepage = "https://rpy2.github.io/";
|
||||
description = "Python interface to R";
|
||||
license = lib.licenses.gpl2Plus;
|
||||
platforms = lib.platforms.unix;
|
||||
maintainers = with lib; [ teams.sage ];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
diff --git a/src/rpy2/rinterface/__init__.py b/src/rpy2/rinterface/__init__.py
|
||||
index 0ba46083..1f4265aa 100644
|
||||
--- a/src/rpy2/rinterface/__init__.py
|
||||
+++ b/src/rpy2/rinterface/__init__.py
|
||||
@@ -1100,6 +1100,15 @@ NA = None
|
||||
NA_Real = None
|
||||
NA_Complex = None
|
||||
|
||||
+def initr_simple() -> typing.Optional[int]:
|
||||
+ """Initialize R's embedded C library."""
|
||||
+ with openrlib.rlock:
|
||||
+ status = embedded._initr()
|
||||
+ atexit.register(endr, 0)
|
||||
+ _rinterface._register_external_symbols()
|
||||
+ _post_initr_setup()
|
||||
+ return status
|
||||
+
|
||||
|
||||
def initr(
|
||||
interactive: typing.Optional[bool] = None,
|
||||
@@ -0,0 +1,19 @@
|
||||
diff --git a/src/rpy2/rinterface_lib/embedded.py b/src/rpy2/rinterface_lib/embedded.py
|
||||
index cc9f7da1..10626f13 100644
|
||||
--- a/src/rpy2/rinterface_lib/embedded.py b/src/rpy2/rinterface_lib/embedded.py
|
||||
@@ -328,6 +328,15 @@ def _initr(
|
||||
_setinitialized()
|
||||
return None
|
||||
|
||||
+ # path to libraries
|
||||
+ existing = os.environ.get('R_LIBS_SITE')
|
||||
+ if existing is not None:
|
||||
+ prefix = existing + ':'
|
||||
+ else:
|
||||
+ prefix = ''
|
||||
+ additional = '@NIX_R_LIBS_SITE@'
|
||||
+ os.environ['R_LIBS_SITE'] = prefix + additional
|
||||
+
|
||||
# TODO: Setting LD_LIBRARY_PATH after the process has started
|
||||
# is too late. Because of this, the line below does not help
|
||||
# address issues where calling R from the command line is working
|
||||
63
pkgs/development/python-modules/rpy2-robjects/default.nix
Normal file
63
pkgs/development/python-modules/rpy2-robjects/default.nix
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
buildPythonPackage,
|
||||
fetchurl,
|
||||
fetchpatch2,
|
||||
isPyPy,
|
||||
R,
|
||||
rpy2-rinterface,
|
||||
ipython,
|
||||
jinja2,
|
||||
numpy,
|
||||
pandas,
|
||||
tzlocal,
|
||||
pytestCheckHook,
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
version = "3.6.2";
|
||||
format = "pyproject";
|
||||
pname = "rpy2-robjects";
|
||||
|
||||
disabled = isPyPy;
|
||||
src = fetchurl {
|
||||
url = "mirror://pypi/${builtins.substring 0 1 pname}/${pname}/${
|
||||
builtins.replaceStrings [ "-" ] [ "_" ] pname
|
||||
}-${version}.tar.gz";
|
||||
hash = "sha256-rJGvMtXE2iNrBaPNaNr7JM2PWogPAHhim48r8CUFQjs=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# https://github.com/rpy2/rpy2/pull/1171#issuecomment-3263994962
|
||||
(fetchpatch2 {
|
||||
url = "https://github.com/rpy2/rpy2/commit/524546eef9b8f7f3d61aeb76d7e7fa7beeabd2d2.patch?full_index=1";
|
||||
hash = "sha256-aR44E8wIBlD7UpQKm7B+aMn2p3FQ8dwBwLwkibIpcuM=";
|
||||
relative = "rpy2-robjects";
|
||||
revert = true;
|
||||
})
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
R # needed at setup time to detect R_HOME (alternatively set R_HOME explicitly)
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
ipython
|
||||
jinja2
|
||||
numpy
|
||||
pandas
|
||||
rpy2-rinterface
|
||||
tzlocal
|
||||
];
|
||||
|
||||
nativeCheckInputs = [ pytestCheckHook ];
|
||||
|
||||
meta = {
|
||||
homepage = "https://rpy2.github.io/";
|
||||
description = "Python interface to R";
|
||||
license = lib.licenses.gpl2Plus;
|
||||
platforms = lib.platforms.unix;
|
||||
maintainers = with lib.maintainers; [ joelmo ];
|
||||
};
|
||||
}
|
||||
@@ -4,99 +4,31 @@
|
||||
buildPythonPackage,
|
||||
fetchPypi,
|
||||
isPyPy,
|
||||
R,
|
||||
libdeflate,
|
||||
rWrapper,
|
||||
rPackages,
|
||||
pcre,
|
||||
xz,
|
||||
bzip2,
|
||||
zlib,
|
||||
zstd,
|
||||
icu,
|
||||
ipython,
|
||||
jinja2,
|
||||
pytz,
|
||||
pandas,
|
||||
numpy,
|
||||
cffi,
|
||||
tzlocal,
|
||||
simplegeneric,
|
||||
rpy2-rinterface,
|
||||
rpy2-robjects,
|
||||
pytestCheckHook,
|
||||
extraRPackages ? [ ],
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
version = "3.6.2";
|
||||
format = "setuptools";
|
||||
version = "3.6.3";
|
||||
format = "pyproject";
|
||||
pname = "rpy2";
|
||||
|
||||
disabled = isPyPy;
|
||||
src = fetchPypi {
|
||||
inherit version pname;
|
||||
hash = "sha256-F06ld2qR0Ds13VYRiJlg4PVFHp0KvqSr/IwL5qhTd9A=";
|
||||
hash = "sha256-lCYYoSUhljAG0i6IqqTUgakjghwDoXQsmb7uci6w/Fo=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# R_LIBS_SITE is used by the nix r package to point to the installed R libraries.
|
||||
# This patch sets R_LIBS_SITE when rpy2 is imported.
|
||||
./rpy2-3.x-r-libs-site.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace 'rpy2/rinterface_lib/embedded.py' --replace '@NIX_R_LIBS_SITE@' "$R_LIBS_SITE"
|
||||
substituteInPlace 'requirements.txt' --replace 'pytest' ""
|
||||
'';
|
||||
|
||||
buildInputs = [
|
||||
pcre
|
||||
xz
|
||||
bzip2
|
||||
zlib
|
||||
zstd
|
||||
icu
|
||||
libdeflate
|
||||
]
|
||||
++ (with rPackages; [
|
||||
# packages expected by the test framework
|
||||
ggplot2
|
||||
dplyr
|
||||
RSQLite
|
||||
broom
|
||||
DBI
|
||||
dbplyr
|
||||
hexbin
|
||||
lazyeval
|
||||
lme4
|
||||
tidyr
|
||||
])
|
||||
++ extraRPackages
|
||||
++ rWrapper.recommendedPackages;
|
||||
|
||||
nativeBuildInputs = [
|
||||
R # needed at setup time to detect R_HOME (alternatively set R_HOME explicitly)
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
ipython
|
||||
jinja2
|
||||
pytz
|
||||
pandas
|
||||
numpy
|
||||
cffi
|
||||
tzlocal
|
||||
simplegeneric
|
||||
rpy2-rinterface
|
||||
rpy2-robjects
|
||||
];
|
||||
|
||||
# https://github.com/rpy2/rpy2/issues/1111
|
||||
disabledTests = [
|
||||
"test_parse_incomplete_error"
|
||||
"test_parse_error"
|
||||
"test_parse_error_when_evaluting"
|
||||
pythonImportsCheck = [
|
||||
"rpy2"
|
||||
];
|
||||
|
||||
nativeCheckInputs = [ pytestCheckHook ];
|
||||
|
||||
meta = {
|
||||
homepage = "https://rpy2.github.io/";
|
||||
description = "Python interface to R";
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
diff --git a/rpy2/rinterface_lib/embedded.py b/rpy2/rinterface_lib/embedded.py
|
||||
index ccd3a315..51fb5da4 100644
|
||||
--- a/rpy2/rinterface_lib/embedded.py
|
||||
+++ b/rpy2/rinterface_lib/embedded.py
|
||||
@@ -276,6 +276,16 @@ def _initr(
|
||||
os.environ.get('LD_LIBRARY_PATH', ''))
|
||||
)
|
||||
)
|
||||
+
|
||||
+ # path to libraries
|
||||
+ existing = os.environ.get('R_LIBS_SITE')
|
||||
+ if existing is not None:
|
||||
+ prefix = existing + ':'
|
||||
+ else:
|
||||
+ prefix = ''
|
||||
+ additional = '@NIX_R_LIBS_SITE@'
|
||||
+ os.environ['R_LIBS_SITE'] = prefix + additional
|
||||
+
|
||||
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)
|
||||
@@ -16135,7 +16135,13 @@ self: super: with self; {
|
||||
|
||||
rpmfluff = callPackage ../development/python-modules/rpmfluff { };
|
||||
|
||||
rpy2 = callPackage ../development/python-modules/rpy2 { inherit (pkgs) zstd; };
|
||||
rpy2 = callPackage ../development/python-modules/rpy2 { };
|
||||
|
||||
rpy2-rinterface = callPackage ../development/python-modules/rpy2-rinterface {
|
||||
inherit (pkgs) zstd;
|
||||
};
|
||||
|
||||
rpy2-robjects = callPackage ../development/python-modules/rpy2-robjects { };
|
||||
|
||||
rpyc = callPackage ../development/python-modules/rpyc { };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user