Skip to content

Commit

Permalink
deps:: auto-detects dependencies if no DESCRIPTION
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Oct 21, 2024
1 parent c8c7a97 commit 5433e06
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions R/type-deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5433e06

Please sign in to comment.