From 6c18b8478920f95c9440141f6572921e8acc1467 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Fri, 20 Sep 2024 19:58:35 -0700 Subject: [PATCH 1/6] Force insert libRBlas in macOS --- radian/app.py | 65 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/radian/app.py b/radian/app.py index e33c672..130c8d6 100644 --- a/radian/app.py +++ b/radian/app.py @@ -20,29 +20,47 @@ def main(cleanup=None): parser = optparse.OptionParser("usage: radian") parser.add_option("-v", "--version", action="store_true", dest="version", help="Get version") parser.add_option("--r-binary", dest="r", help="Path to R binary") - parser.add_option("--profile", dest="profile", help="Path to .radian_profile, ignore both global and local profiles") - parser.add_option("-q", "--quiet", "--silent", action="store_true", dest="quiet", help="Don't print startup message") - parser.add_option("--no-environ", action="store_true", dest="no_environ", help="Don't read the site and user environment files") - parser.add_option("--no-site-file", action="store_true", dest="no_site_file", help="Don't read the site-wide Rprofile") - parser.add_option("--no-init-file", action="store_true", dest="no_init_file", help="Don't read the user R profile") - parser.add_option("--local-history", action="store_true", dest="local_history", help="Force using local history file") - parser.add_option("--global-history", action="store_true", dest="global_history", help="Force using global history file") - parser.add_option("--no-history", action="store_true", dest="no_history", help="Don't load any history files") - parser.add_option("--vanilla", action="store_true", dest="vanilla", help="Combine --no-history --no-environ --no-site-file --no-init-file") - parser.add_option("--save", action="store_true", dest="save", help="Do save workspace at the end of the session") + parser.add_option("--profile", dest="profile", + help="Path to .radian_profile, ignore both global and local profiles") + parser.add_option("-q", "--quiet", "--silent", action="store_true", + dest="quiet", help="Don't print startup message") + parser.add_option("--no-environ", action="store_true", dest="no_environ", + help="Don't read the site and user environment files") + parser.add_option("--no-site-file", action="store_true", dest="no_site_file", + help="Don't read the site-wide Rprofile") + parser.add_option("--no-init-file", action="store_true", + dest="no_init_file", help="Don't read the user R profile") + parser.add_option("--local-history", action="store_true", + dest="local_history", help="Force using local history file") + parser.add_option("--global-history", action="store_true", + dest="global_history", help="Force using global history file") + parser.add_option("--no-history", action="store_true", + dest="no_history", help="Don't load any history files") + parser.add_option("--vanilla", action="store_true", dest="vanilla", + help="Combine --no-history --no-environ --no-site-file --no-init-file") + parser.add_option("--save", action="store_true", dest="save", + help="Do save workspace at the end of the session") parser.add_option("--ask-save", action="store_true", dest="ask_save", help="Ask to save R data") - parser.add_option("--restore-data", action="store_true", dest="restore_data", help="Restore previously saved objects") + parser.add_option("--restore-data", action="store_true", dest="restore_data", + help="Restore previously saved objects") parser.add_option("--debug", action="store_true", dest="debug", help="Debug mode") - parser.add_option("--coverage", action="store_true", dest="coverage", help=optparse.SUPPRESS_HELP) - parser.add_option("--cprofile", action="store_true", dest="cprofile", help=optparse.SUPPRESS_HELP) + parser.add_option("--coverage", action="store_true", + dest="coverage", help=optparse.SUPPRESS_HELP) + parser.add_option("--cprofile", action="store_true", + dest="cprofile", help=optparse.SUPPRESS_HELP) # we accept these options, but never check them parser.add_option("--no-save", action="store_true", dest="no_save", help=optparse.SUPPRESS_HELP) - parser.add_option("--no-restore-data", action="store_true", dest="no_restore_data", help=optparse.SUPPRESS_HELP) - parser.add_option("--no-restore-history", action="store_true", dest="no_restore_history", help=optparse.SUPPRESS_HELP) - parser.add_option("--no-restore", action="store_true", dest="no_restore", help=optparse.SUPPRESS_HELP) - parser.add_option("--no-readline", action="store_true", dest="no_readline", help=optparse.SUPPRESS_HELP) - parser.add_option("--interactive", action="store_true", dest="interactive", help=optparse.SUPPRESS_HELP) + parser.add_option("--no-restore-data", action="store_true", + dest="no_restore_data", help=optparse.SUPPRESS_HELP) + parser.add_option("--no-restore-history", action="store_true", + dest="no_restore_history", help=optparse.SUPPRESS_HELP) + parser.add_option("--no-restore", action="store_true", + dest="no_restore", help=optparse.SUPPRESS_HELP) + parser.add_option("--no-readline", action="store_true", + dest="no_readline", help=optparse.SUPPRESS_HELP) + parser.add_option("--interactive", action="store_true", + dest="interactive", help=optparse.SUPPRESS_HELP) options, args = parser.parse_args() @@ -110,6 +128,17 @@ def main(cleanup=None): else: LD_LIBRARY_PATH = R_LD_LIBRARY_PATH os.environ[ld_library_var] = LD_LIBRARY_PATH + + if sys.platform == "darwin": + # macOS python injects Accelarate Blas automatically + # note that it may be ignored for SIP protected python. + libRBlas = os.path.join(libPath, "libRblas.dylib") + if "DYLD_INSERT_LIBRARIES" not in os.environ: + os.environ["DYLD_INSERT_LIBRARIES"] = libRBlas + else: + os.environ["DYLD_INSERT_LIBRARIES"] = "{}:{}".format( + os.environ["DYLD_INSERT_LIBRARIES"], libRBlas) + if sys.argv[0].endswith("radian"): os.execv(sys.argv[0], sys.argv) else: From 27fddfcfc3b75a07cb9ca1e3b28a285bafa5a4a9 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Fri, 20 Sep 2024 20:12:30 -0700 Subject: [PATCH 2/6] use master branch --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a8dd2fd..f16ebbd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: - name: Install required R packages for testing run: Rscript -e "install.packages(c('remotes', 'askpass'))" - name: Install required R packages for testing - run: Rscript -e "remotes::install_github('rstudio/reticulate#1670')" + run: Rscript -e "remotes::install_github('rstudio/reticulate')" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install and run tests From e33953ad19fe63335181a0a4468c94fd1922c0bf Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Fri, 20 Sep 2024 21:23:15 -0700 Subject: [PATCH 3/6] bump to 0.6.14 --- CHANGELOG.md | 6 ++++++ radian/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b619ae..e2a7658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v0.6.14 + + +# v0.6.13 + - fix line wrapping for windows terminal (#484) + # v0.6.12 - fix color printing issue https://github.com/randy3k/radian/issues/468 diff --git a/radian/__init__.py b/radian/__init__.py index 372d797..90daf78 100644 --- a/radian/__init__.py +++ b/radian/__init__.py @@ -1,5 +1,5 @@ from .app import get_app, main -__version__ = '0.6.13' +__version__ = '0.6.14' __all__ = ["get_app", "main"] From b6a7293d1ee34088b02a43ef2fb9cf5f5d125759 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Fri, 20 Sep 2024 21:39:48 -0700 Subject: [PATCH 4/6] avoid DYLD_INSERT_LIBRARIES to propagate --- radian/app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/radian/app.py b/radian/app.py index 130c8d6..07a5480 100644 --- a/radian/app.py +++ b/radian/app.py @@ -96,6 +96,10 @@ def main(cleanup=None): if not sys.platform.startswith("win"): libPath = os.path.join(r_home, "lib") ldpaths = os.path.join(r_home, "etc", "ldpaths") + + if "DYLD_INSERT_LIBRARIES" in os.environ: + del os.environ['DYLD_INSERT_LIBRARIES'] + if ( "R_LD_LIBRARY_PATH" not in os.environ or libPath not in os.environ["R_LD_LIBRARY_PATH"] From 42abb2f9e9a0e30331f19bc87b2d272ad3b549b5 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Fri, 20 Sep 2024 21:48:37 -0700 Subject: [PATCH 5/6] improve DYLD_INSERT_LIBRARIES --- radian/app.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/radian/app.py b/radian/app.py index 07a5480..458dbda 100644 --- a/radian/app.py +++ b/radian/app.py @@ -96,9 +96,18 @@ def main(cleanup=None): if not sys.platform.startswith("win"): libPath = os.path.join(r_home, "lib") ldpaths = os.path.join(r_home, "etc", "ldpaths") - - if "DYLD_INSERT_LIBRARIES" in os.environ: - del os.environ['DYLD_INSERT_LIBRARIES'] + libRBlas = os.path.join(libPath, "libRblas.dylib") + + if sys.platform == "darwin": + # avoid libRBlas to propagate downstream + if "DYLD_INSERT_LIBRARIES" in os.environ: + libs = [ + lib for lib in os.environ['DYLD_INSERT_LIBRARIES'].split(":") if lib != libRBlas + ] + if libs: + os.environ['DYLD_INSERT_LIBRARIES'] = ":".join(libs) + else: + del os.environ['DYLD_INSERT_LIBRARIES'] if ( "R_LD_LIBRARY_PATH" not in os.environ @@ -134,9 +143,6 @@ def main(cleanup=None): os.environ[ld_library_var] = LD_LIBRARY_PATH if sys.platform == "darwin": - # macOS python injects Accelarate Blas automatically - # note that it may be ignored for SIP protected python. - libRBlas = os.path.join(libPath, "libRblas.dylib") if "DYLD_INSERT_LIBRARIES" not in os.environ: os.environ["DYLD_INSERT_LIBRARIES"] = libRBlas else: From bb1f3718113eebbe26e86358d32f5b5b39ff86ec Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Fri, 20 Sep 2024 22:10:30 -0700 Subject: [PATCH 6/6] Update CHANGELOG [skip ci] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2a7658..61f7916 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v0.6.14 - + - Force loading libRBlas in macOS # v0.6.13 - fix line wrapping for windows terminal (#484)