summaryrefslogtreecommitdiffstats
path: root/pre_commit/languages/r.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-21 19:59:08 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-21 19:59:08 +0000
commit20ff60e9f0e8528b00b03e036fa3d41743d53dfa (patch)
tree7baccf4096b08411ca191790015c7f6c835a85c7 /pre_commit/languages/r.py
parentAdding upstream version 2.16.0. (diff)
downloadpre-commit-20ff60e9f0e8528b00b03e036fa3d41743d53dfa.tar.xz
pre-commit-20ff60e9f0e8528b00b03e036fa3d41743d53dfa.zip
Adding upstream version 2.17.0.upstream/2.17.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/languages/r.py')
-rw-r--r--pre_commit/languages/r.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/pre_commit/languages/r.py b/pre_commit/languages/r.py
index d573775..e034e39 100644
--- a/pre_commit/languages/r.py
+++ b/pre_commit/languages/r.py
@@ -8,6 +8,7 @@ from typing import Tuple
from pre_commit.envcontext import envcontext
from pre_commit.envcontext import PatchesT
+from pre_commit.envcontext import UNSET
from pre_commit.hook import Hook
from pre_commit.languages import helpers
from pre_commit.prefix import Prefix
@@ -23,6 +24,7 @@ healthy = helpers.basic_healthy
def get_env_patch(venv: str) -> PatchesT:
return (
('R_PROFILE_USER', os.path.join(venv, 'activate.R')),
+ ('RENV_PROJECT', UNSET),
)
@@ -55,6 +57,10 @@ def _prefix_if_non_local_file_entry(
return (path,)
+def _rscript_exec() -> str:
+ return os.path.join(os.getenv('R_HOME', ''), 'Rscript')
+
+
def _entry_validate(entry: Sequence[str]) -> None:
"""
Allowed entries:
@@ -95,8 +101,9 @@ def install_environment(
os.makedirs(env_dir, exist_ok=True)
shutil.copy(prefix.path('renv.lock'), env_dir)
shutil.copytree(prefix.path('renv'), os.path.join(env_dir, 'renv'))
+
cmd_output_b(
- 'Rscript', '--vanilla', '-e',
+ _rscript_exec(), '--vanilla', '-e',
f"""\
prefix_dir <- {prefix.prefix_dir!r}
options(
@@ -130,7 +137,7 @@ def install_environment(
if additional_dependencies:
with in_env(prefix, version):
cmd_output_b(
- 'Rscript', *RSCRIPT_OPTS, '-e',
+ _rscript_exec(), *RSCRIPT_OPTS, '-e',
'renv::install(commandArgs(trailingOnly = TRUE))',
*additional_dependencies,
cwd=env_dir,