mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
Merge pull request #2277 from lorenzwalthert/always-binary
Avoid build-time dependencies by prioritising binary over source dependencies for R
This commit is contained in:
commit
2ed0eaa121
1 changed files with 20 additions and 5 deletions
|
|
@ -103,9 +103,7 @@ def install_environment(
|
||||||
shutil.copy(prefix.path('renv.lock'), env_dir)
|
shutil.copy(prefix.path('renv.lock'), env_dir)
|
||||||
shutil.copytree(prefix.path('renv'), os.path.join(env_dir, 'renv'))
|
shutil.copytree(prefix.path('renv'), os.path.join(env_dir, 'renv'))
|
||||||
|
|
||||||
cmd_output_b(
|
r_code_inst_environment = f"""\
|
||||||
_rscript_exec(), '--vanilla', '-e',
|
|
||||||
f"""\
|
|
||||||
prefix_dir <- {prefix.prefix_dir!r}
|
prefix_dir <- {prefix.prefix_dir!r}
|
||||||
options(
|
options(
|
||||||
repos = c(CRAN = "https://cran.rstudio.com"),
|
repos = c(CRAN = "https://cran.rstudio.com"),
|
||||||
|
|
@ -132,19 +130,36 @@ def install_environment(
|
||||||
if (is_package) {{
|
if (is_package) {{
|
||||||
renv::install(prefix_dir)
|
renv::install(prefix_dir)
|
||||||
}}
|
}}
|
||||||
""",
|
"""
|
||||||
|
|
||||||
|
cmd_output_b(
|
||||||
|
_rscript_exec(), '--vanilla', '-e',
|
||||||
|
_inline_r_setup(r_code_inst_environment),
|
||||||
cwd=env_dir,
|
cwd=env_dir,
|
||||||
)
|
)
|
||||||
if additional_dependencies:
|
if additional_dependencies:
|
||||||
|
r_code_inst_add = 'renv::install(commandArgs(trailingOnly = TRUE))'
|
||||||
with in_env(prefix, version):
|
with in_env(prefix, version):
|
||||||
cmd_output_b(
|
cmd_output_b(
|
||||||
_rscript_exec(), *RSCRIPT_OPTS, '-e',
|
_rscript_exec(), *RSCRIPT_OPTS, '-e',
|
||||||
'renv::install(commandArgs(trailingOnly = TRUE))',
|
_inline_r_setup(r_code_inst_add),
|
||||||
*additional_dependencies,
|
*additional_dependencies,
|
||||||
cwd=env_dir,
|
cwd=env_dir,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _inline_r_setup(code: str) -> str:
|
||||||
|
"""
|
||||||
|
Some behaviour of R cannot be configured via env variables, but can
|
||||||
|
only be configured via R options once R has started. These are set here.
|
||||||
|
"""
|
||||||
|
with_option = f"""\
|
||||||
|
options(install.packages.compile.from.source = "never")
|
||||||
|
{code}
|
||||||
|
"""
|
||||||
|
return with_option
|
||||||
|
|
||||||
|
|
||||||
def run_hook(
|
def run_hook(
|
||||||
hook: Hook,
|
hook: Hook,
|
||||||
file_args: Sequence[str],
|
file_args: Sequence[str],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue