Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force insert libRBlas in macOS #492

Merged
merged 6 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.6.14
- Force loading libRBlas in macOS

# v0.6.13
- fix line wrapping for windows terminal (#484)

# v0.6.12
- fix color printing issue https://github.com/randy3k/radian/issues/468

Expand Down
2 changes: 1 addition & 1 deletion radian/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .app import get_app, main

__version__ = '0.6.13'
__version__ = '0.6.14'

__all__ = ["get_app", "main"]
75 changes: 57 additions & 18 deletions radian/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -78,6 +96,19 @@ 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")
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
or libPath not in os.environ["R_LD_LIBRARY_PATH"]
Expand Down Expand Up @@ -110,6 +141,14 @@ def main(cleanup=None):
else:
LD_LIBRARY_PATH = R_LD_LIBRARY_PATH
os.environ[ld_library_var] = LD_LIBRARY_PATH

if sys.platform == "darwin":
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:
Expand Down