From 5433e06dc02b69ac274aa35c70430a4de69bfaa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Mon, 21 Oct 2024 14:34:02 +0200 Subject: [PATCH] deps:: auto-detects dependencies if no DESCRIPTION --- R/type-deps.R | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/R/type-deps.R b/R/type-deps.R index 8f63efbe..45810bb5 100644 --- a/R/type-deps.R +++ b/R/type-deps.R @@ -14,8 +14,13 @@ parse_remote_deps <- function(specs, config, ...) { resolve_remote_deps <- function(remote, direct, config, cache, dependencies, ...) { - ret <- resolve_remote_local(remote, direct, config, cache, - dependencies, ...) + if (file.exists(file.path(remote$path, "DESCRIPTION"))) { + ret <- resolve_remote_local(remote, direct, config, cache, + dependencies, ...) + } else { + ret <- resolve_remote_local_autodeps(remote, direct, config, cache, + dependencies, ...) + } # We need to do some extra work for the case when a dependency # depends on the ref itself. E.g. when in pak::local_install_dev_deps() @@ -54,6 +59,28 @@ resolve_remote_deps <- function(remote, direct, config, cache, ret2 } +resolve_remote_local_autodeps <- function(remote, direct, config, cache, + dependencies, ...) { + deps <- scan_deps(remote$path) + tmpdesc <- tempfile() + on.exit(unlink(tmpdesc), add = TRUE) + dsc <- desc::desc("!new") + hard <- deps$package[deps$type == "prod"] + soft <- deps$package[deps$type != "prod"] + for (p in hard) dsc$set_dep(p, type = "Depends") + for (s in soft) dsc$set_dep(p, type = "Suggests") + dsc$write(tmpdesc) + resolve_from_description( + tmpdesc, + paste0("file://", normalizePath(tmpdesc)), + remote, + direct, + config, + cache, + dependencies[[2 - direct]] + ) +} + download_remote_deps <- function(resolution, target, target_tree, config, cache, which, on_progress) { ## Nothing to do here