Skip to content

Commit

Permalink
fix: use full path to R executable when running lme4 analysis in rsetup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Oct 18, 2024
1 parent f31c69f commit eacf2a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.62.2
- fix: use full path to R executable when running lme4 analysis in rsetup
- enh: properly catch CalledProcessError in run_command
- enh: improve search for R executable path
- ref: replace sp.check_output with run_command in lme4 submodule
Expand Down
15 changes: 9 additions & 6 deletions dclab/lme4/rsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def get_r_script_path():
def get_r_version():
"""Return the full R version string"""
require_r()
cmd = ("R", "--version")
logger.debug(f"Looking for R version with: {cmd}")
cmd = (str(get_r_path()), "--version")
logger.debug(f"Looking for R version with: {' '.join(cmd)}")
tmp = run_command(cmd, stderr=sp.STDOUT)
r_version = tmp.decode("ascii", "ignore").split(os.linesep)
if r_version[0].startswith("WARNING"):
Expand All @@ -92,7 +92,8 @@ def has_lme4():
return True
require_r()
for pkg in ["lme4", "statmod", "nloptr"]:
res = run_command(("R", "-q", "-e", f"system.file(package='{pkg}')"))
res = run_command(
(str(get_r_path()), "-q", "-e", f"system.file(package='{pkg}')"))
if not res.split("[1]")[1].count(pkg):
avail = False
break
Expand All @@ -107,7 +108,7 @@ def has_r():
if _has_r:
return True
try:
hasr = bool(get_r_path())
hasr = get_r_path().is_file()
except RNotFoundError:
hasr = False
if hasr:
Expand All @@ -125,8 +126,10 @@ def require_lme4():
require_r()
if not has_lme4():
run_command((
"R", "-e", "install.packages(c('statmod','nloptr','lme4'),"
"repos='http://cran.rstudio.org')"))
get_r_path(), "-e",
"install.packages(c('statmod','nloptr','lme4'),"
"repos='http://cran.rstudio.org')" # noqa: E131
))


def require_r():
Expand Down

0 comments on commit eacf2a6

Please sign in to comment.