Skip to content

Commit f69dd69

Browse files
author
Release Manager
committed
gh-38777: Check the system R in SPKG rpy2 <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> It is problematic to put a dummy package into the dependencies list. For instance, see #38774. We move the check for the system R to `spkg-configure.m4` of SPKG rpy2. Then we can replace R in the dependencies list with rpy2. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> #38774 (merged here) URL: #38777 Reported by: Kwankyu Lee Reviewer(s):
2 parents 367b516 + 12fd0db commit f69dd69

File tree

4 files changed

+38
-26
lines changed

4 files changed

+38
-26
lines changed

build/pkgs/r/spkg-configure.m4

Lines changed: 0 additions & 14 deletions
This file was deleted.

build/pkgs/r_jupyter/dependencies

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
notebook r
1+
notebook rpy2
2+
3+
----------
4+
R is the real dependency. But SPKG r is a dummy package, and does not install R.
5+
Since SPKG rpy2 checks for the system R, we put rpy2 as a dependency instead.

build/pkgs/rpy2/dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cffi tzlocal pytz jinja2 | $(PYTHON_TOOLCHAIN) pycparser $(PYTHON)
1+
cffi tzlocal pytz jinja2 | $(PYTHON_TOOLCHAIN) pycparser $(PYTHON)
22

33
----------
44
All lines of this file are ignored except the first.

build/pkgs/rpy2/spkg-configure.m4

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
11
SAGE_SPKG_CONFIGURE([rpy2], [
2-
SAGE_PYTHON_PACKAGE_CHECK([rpy2])
2+
SAGE_PYTHON_PACKAGE_CHECK([rpy2])
33
], [dnl REQUIRED-CHECK
4-
AC_REQUIRE([SAGE_SPKG_CONFIGURE_R])
5-
dnl rpy2 is only needed when there is a usable system R
6-
AS_VAR_IF([sage_spkg_install_r], [yes], [dnl
7-
AS_VAR_IF([sage_use_system_r], [installed], [dnl
8-
dnl Legacy SPKG installation of r
9-
AS_VAR_SET([SPKG_REQUIRE], [yes])
10-
], [dnl No system package, no legacy SPKG installation
11-
AS_VAR_SET([SPKG_REQUIRE], [no])
12-
])
4+
dnl rpy2 is only needed when there is a usable system R
5+
dnl Check for the R installation and version
6+
dnl https://rpy2.github.io/doc/v3.4.x/html/overview.html#requirements
7+
m4_pushdef([SAGE_R_MINVER], ["3.5"])
8+
PKG_CHECK_MODULES([R], [libR >= SAGE_R_MINVER], [dnl
9+
AC_PATH_PROG([R_EXECUTABLE], [R])
10+
AS_IF([test "x$R_EXECUTABLE" = x], [dnl
11+
AC_MSG_NOTICE([R is not found])
12+
dnl No R found, so do not require rpy2 package
13+
AS_VAR_SET([SPKG_REQUIRE], [no])
14+
], [dnl Extract R version
15+
AC_MSG_CHECKING([for version of R executable])
16+
R_VERSION=$($R_EXECUTABLE --version | sed -n 's/^R version \([[0-9.]]*\).*/\1/p')
17+
AC_MSG_RESULT([$R_VERSION])
18+
dnl Extract libR version
19+
AC_MSG_CHECKING([for version of libR])
20+
LIBR_VERSION=$(pkg-config --modversion libR)
21+
AC_MSG_RESULT([$LIBR_VERSION])
22+
dnl Compare R and libR versions
23+
AS_IF([test "x$R_VERSION" = "x$LIBR_VERSION"], [dnl
24+
AC_MSG_NOTICE([R and libR versions match ($R_VERSION)])
25+
dnl Good system R is found, require rpy2 package
26+
AS_VAR_SET([SPKG_REQUIRE], [yes])
27+
], [dnl R and libR versions do not match
28+
AC_MSG_NOTICE([R version ($R_VERSION) does not match libR version ($LIBR_VERSION)])
29+
AS_VAR_SET([SPKG_REQUIRE], [no])
30+
])
1331
])
32+
], [dnl libR not found or outdated
33+
AS_VAR_SET([SPKG_REQUIRE], [no])
34+
])
35+
m4_popdef([SAGE_R_MINVER])
1436
])

0 commit comments

Comments
 (0)