Skip to content

Commit

Permalink
sagemathgh-38777: Check the system R in SPKG rpy2
Browse files Browse the repository at this point in the history
    
<!-- ^ 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 sagemath#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 sagemath#12345". -->

It is problematic to put a dummy package into the dependencies list. For
instance, see sagemath#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,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->

sagemath#38774 (merged here)
    
URL: sagemath#38777
Reported by: Kwankyu Lee
Reviewer(s):
  • Loading branch information
Release Manager committed Oct 8, 2024
2 parents 5fe66da + 12fd0db commit 3483150
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
14 changes: 0 additions & 14 deletions build/pkgs/r/spkg-configure.m4

This file was deleted.

6 changes: 5 additions & 1 deletion build/pkgs/r_jupyter/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
notebook r
notebook rpy2

----------
R is the real dependency. But SPKG r is a dummy package, and does not install R.
Since SPKG rpy2 checks for the system R, we put rpy2 as a dependency instead.
2 changes: 1 addition & 1 deletion build/pkgs/rpy2/dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cffi tzlocal pytz jinja2 | $(PYTHON_TOOLCHAIN) pycparser $(PYTHON)
cffi tzlocal pytz jinja2 | $(PYTHON_TOOLCHAIN) pycparser $(PYTHON)

----------
All lines of this file are ignored except the first.
42 changes: 32 additions & 10 deletions build/pkgs/rpy2/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
SAGE_SPKG_CONFIGURE([rpy2], [
SAGE_PYTHON_PACKAGE_CHECK([rpy2])
SAGE_PYTHON_PACKAGE_CHECK([rpy2])
], [dnl REQUIRED-CHECK
AC_REQUIRE([SAGE_SPKG_CONFIGURE_R])
dnl rpy2 is only needed when there is a usable system R
AS_VAR_IF([sage_spkg_install_r], [yes], [dnl
AS_VAR_IF([sage_use_system_r], [installed], [dnl
dnl Legacy SPKG installation of r
AS_VAR_SET([SPKG_REQUIRE], [yes])
], [dnl No system package, no legacy SPKG installation
AS_VAR_SET([SPKG_REQUIRE], [no])
])
dnl rpy2 is only needed when there is a usable system R
dnl Check for the R installation and version
dnl https://rpy2.github.io/doc/v3.4.x/html/overview.html#requirements
m4_pushdef([SAGE_R_MINVER], ["3.5"])
PKG_CHECK_MODULES([R], [libR >= SAGE_R_MINVER], [dnl
AC_PATH_PROG([R_EXECUTABLE], [R])
AS_IF([test "x$R_EXECUTABLE" = x], [dnl
AC_MSG_NOTICE([R is not found])
dnl No R found, so do not require rpy2 package
AS_VAR_SET([SPKG_REQUIRE], [no])
], [dnl Extract R version
AC_MSG_CHECKING([for version of R executable])
R_VERSION=$($R_EXECUTABLE --version | sed -n 's/^R version \([[0-9.]]*\).*/\1/p')
AC_MSG_RESULT([$R_VERSION])
dnl Extract libR version
AC_MSG_CHECKING([for version of libR])
LIBR_VERSION=$(pkg-config --modversion libR)
AC_MSG_RESULT([$LIBR_VERSION])
dnl Compare R and libR versions
AS_IF([test "x$R_VERSION" = "x$LIBR_VERSION"], [dnl
AC_MSG_NOTICE([R and libR versions match ($R_VERSION)])
dnl Good system R is found, require rpy2 package
AS_VAR_SET([SPKG_REQUIRE], [yes])
], [dnl R and libR versions do not match
AC_MSG_NOTICE([R version ($R_VERSION) does not match libR version ($LIBR_VERSION)])
AS_VAR_SET([SPKG_REQUIRE], [no])
])
])
], [dnl libR not found or outdated
AS_VAR_SET([SPKG_REQUIRE], [no])
])
m4_popdef([SAGE_R_MINVER])
])

0 comments on commit 3483150

Please sign in to comment.