Skip to content

Commit

Permalink
Update embedded (dev) pkgdepends
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Dec 10, 2023
1 parent 1c4327e commit ecbb289
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 34 deletions.
11 changes: 6 additions & 5 deletions src/library/pkgdepends/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@ Imports: callr (>= 3.3.1), cli (>= 3.6.0), curl, desc (>= 1.2.0),
filelock (>= 1.0.2), jsonlite, lpSolve, pkgbuild (>= 1.0.2),
pkgcache (>= 2.2.0), processx (>= 3.4.2), ps, R6, stats, utils,
zip (>= 2.3.0)
Suggests: asciicast (>= 2.2.0.9000), covr, debugme, fansi, fs, glue,
htmlwidgets, mockery, pak, pingr (>= 2.0.0), rmarkdown,
rstudioapi, spelling, svglite, testthat (>= 3.2.0), tibble,
webfakes (>= 1.1.5.9000), withr (>= 2.1.1)
Remotes: r-lib/desc
Suggests: asciicast (>= 2.2.0.9000), codetools, covr, debugme, fansi,
fs, glue, htmlwidgets, mockery, pak, pingr (>= 2.0.0),
rmarkdown, rstudioapi, spelling, svglite, testthat (>= 3.2.0),
tibble, webfakes (>= 1.1.5.9000), withr (>= 2.1.1)
Config/Needs/coverage: r-lib/asciicast, covr
Config/Needs/website: r-lib/asciicast, pkgdown (>= 2.0.2),
tidyverse/tidytemplate
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2023-11-21 21:52:53 UTC; gaborcsardi
Packaged: 2023-12-10 20:41:52 UTC; gaborcsardi
Author: Gábor Csárdi [aut, cre],
Posit Software, PBC [cph, fnd]
Maintainer: Gábor Csárdi <[email protected]>
5 changes: 4 additions & 1 deletion src/library/pkgdepends/R/install-binary.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ add_metadata <- function(pkg_path, metadata) {
source_desc <- file.path(pkg_path, "DESCRIPTION")
binary_desc <- file.path(pkg_path, "Meta", "package.rds")
if (file.exists(source_desc)) {
do.call(desc::desc_set, c(as.list(metadata), list(file = source_desc)))
do.call(
desc::desc_set,
c(as.list(metadata), list(file = source_desc, check = FALSE))
)
}

if (file.exists(binary_desc)) {
Expand Down
10 changes: 10 additions & 0 deletions src/library/pkgdepends/R/install-plan.R
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,16 @@ make_build_process <- function(path, pkg, tmp_dir, lib, vignettes,
## with_libpath() is needed for newer callr, which forces the current
## lib path in the child process.
mkdirp(tmplib <- tempfile("pkg-lib"))
# Otherwise it is loaded with a modified library path, so potentially from the
# wrong place, especially in pak
loadNamespace("pkgbuild")
loadNamespace("desc")
loadNamespace("callr")
loadNamespace("processx")
loadNamespace("cli")
loadNamespace("ps")
# loadNamespace("R6") # not needed, built time dependency

withr_with_libpaths(c(tmplib, lib), action = "prefix",
pkgbuild::pkgbuild_process$new(
path, tmp_dir, binary = binary, vignettes = vignettes,
Expand Down
27 changes: 14 additions & 13 deletions src/library/pkgdepends/R/solve.R
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ pkgplan_export_install_plan <- function(self, private, plan_file, version) {
for (i in seq_along(spkgs)) {
elt <- spkgs[[i]]
for (j in seq_along(elt)) {
elt[[j]]$sysreq <- jsonlite::unbox(elt[[j]]$sysreq)
elt[[j]]$sysreq <- tojson$unbox(elt[[j]]$sysreq)
elt[[j]]$packages_missing <- NULL
}
if (!is.null(elt)) spkgs[[i]] <- elt
Expand All @@ -1150,14 +1150,14 @@ pkgplan_export_install_plan <- function(self, private, plan_file, version) {

packages$params <- lapply(
packages$params,
function(x) lapply(as.list(x), jsonlite::unbox)
function(x) lapply(as.list(x), tojson$unbox)
)

plan <- list(
lockfile_version = jsonlite::unbox(version),
os = jsonlite::unbox(utils::sessionInfo()$running),
r_version = jsonlite::unbox(R.Version()$version.string),
platform = jsonlite::unbox(R.Version()$platform),
lockfile_version = tojson$unbox(version),
os = tojson$unbox(utils::sessionInfo()$running),
r_version = tojson$unbox(R.Version()$version.string),
platform = tojson$unbox(R.Version()$platform),
packages = packages
)

Expand All @@ -1166,10 +1166,10 @@ pkgplan_export_install_plan <- function(self, private, plan_file, version) {
self$get_solution()$data$sysreqs_packages,
private$config$get("sysreqs_platform")
)
sysreqs$os <- jsonlite::unbox(sysreqs$os)
sysreqs$distribution <- jsonlite::unbox(sysreqs$distribution)
sysreqs$version <- jsonlite::unbox(sysreqs$version)
sysreqs$url <- jsonlite::unbox(sysreqs$url)
sysreqs$os <- tojson$unbox(sysreqs$os)
sysreqs$distribution <- tojson$unbox(sysreqs$distribution)
sysreqs$version <- tojson$unbox(sysreqs$version)
sysreqs$url <- tojson$unbox(sysreqs$url)
sysreqs$total <- NULL
plan$sysreqs <- sysreqs
}
Expand All @@ -1178,10 +1178,11 @@ pkgplan_export_install_plan <- function(self, private, plan_file, version) {
writeLines(txt, plan_file)
}

as_json_lite_plan <- function(liteplan, pretty = as.logical(Sys.getenv("PKG_PRETTY_JSON", "TRUE")), ...) {
tolist1 <- function(x) lapply(x, function(v) lapply(as.list(v), jsonlite::unbox))
as_json_lite_plan <- function(liteplan) {
tolist1 <- function(x) lapply(x, function(v) lapply(as.list(v), tojson$unbox))
liteplan$packages$metadata <- tolist1(liteplan$packages$metadata)
jsonlite::toJSON(liteplan, pretty = pretty, ...)
json <- tojson$write_str(liteplan, opts = list(pretty = TRUE))
json
}

calculate_lib_status <- function(sol, res) {
Expand Down
5 changes: 4 additions & 1 deletion src/library/pkgdepends/R/type-github.R
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,10 @@ github_query <- function(query,
query; url; headers; list(...)

headers <- c(headers, type_github_get_headers())
data <- jsonlite::toJSON(list(query = query), auto_unbox = TRUE)
data <- tojson$write_str(
list(query = query),
opts = list(auto_unbox = TRUE)
)
resp <- NULL
obj <- NULL

Expand Down
28 changes: 14 additions & 14 deletions src/library/pkgdepends/R/zzz-pkgdepends-config.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
cache_dir = list(
type = "string",
default = detect_download_cache_dir,
default = function() detect_download_cache_dir(),
docs =
"Directory to download the packages to. Defaults to a temporary
directory within the R session temporary directory, see
Expand All @@ -95,7 +95,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
cran_mirror = list(
type = "string",
default = default_cran_mirror,
default = function() default_cran_mirror(),
docs =
"CRAN mirror to use. Defaults to the `repos` option
(see [base::options()]), if that's not set then
Expand All @@ -110,7 +110,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
dependencies = list(
type = "dependencies",
default = pkg_dep_types_hard,
default = function() pkg_dep_types_hard(),
# pak functions take this as an argument, so we do not need it, for now
pak = FALSE,
docs =
Expand Down Expand Up @@ -163,7 +163,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
metadata_update_after = list(
type = "difftime",
default = default_update_after,
default = function() default_update_after(),
docs =
"A time interval as a [difftime] object. pkgdepends will update the
metadata cache if it is older than this. The default is one day.
Expand Down Expand Up @@ -192,7 +192,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
platforms = list(
type = "character",
default = default_platforms,
default = function() default_platforms(),
# TODO: do not link to pkgdepends docs from pak
docs =
"Character vector of platforms to _download_ or _install_ packages
Expand All @@ -204,7 +204,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
r_versions = list(
type = "character",
default = current_r_version,
default = function() current_r_version(),
check = is_r_version_list,
docs =
"Character vector, R versions to download or install
Expand All @@ -214,7 +214,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
sysreqs = list(
type = "flag",
default = default_sysreqs,
default = function(config) default_sysreqs(config),
docs =
"Whether to automatically look up and install system requirements.
If `TRUE`, then `r pak_or_pkgdepends()` will try to install required
Expand Down Expand Up @@ -260,7 +260,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
sysreqs_platform = list(
type = "string",
default = default_sysreqs_platform,
default = function() default_sysreqs_platform(),
docs =
"The platform to use for system requirements lookup. On Linux, where
system requirements are currently supported, it must be a string
Expand All @@ -271,7 +271,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
sysreqs_rspm_repo_id = list(
type = "string",
default = default_sysreqs_rspm_repo_id,
default = function() default_sysreqs_rspm_repo_id(),
docs =
"Posit Package Manager (formerly RStudio Package Manager) repository
id to use for CRAN system requirements lookup. Defaults to the
Expand All @@ -282,7 +282,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
sysreqs_rspm_url = list(
type = "string",
default = default_sysreqs_rspm_url,
default = function() default_sysreqs_rspm_url(),
docs = "Root URL of Posit Package Manager (formerly RStudio Package
Manager) for system requirements lookup. By default the `RSPM_ROOT`
environment variable is used, if set. If not set,
Expand All @@ -292,7 +292,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
sysreqs_sudo = list(
type = "flag",
default = default_sysreqs_sudo,
default = function() default_sysreqs_sudo(),
docs =
"Whether to use `sudo` to install system requirements,
on Unix. By default it is `TRUE` on Linux if the effective user id
Expand All @@ -302,7 +302,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
sysreqs_update = list(
type = "flag",
default = default_sysreqs_update,
default = function() default_sysreqs_update(),
docs =
"Whether to try to update system packages that are already installed.
It defaults to `TRUE` on CI systems: if the `CI` environment
Expand All @@ -312,7 +312,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
sysreqs_verbose = list(
type = "flag",
default = default_sysreqs_verbose,
default = function() default_sysreqs_verbose(),
docs =
"Whether to echo the output of system requirements installation.
Defaults to `TRUE` if the `CI` environment variable is set."
Expand All @@ -330,7 +330,7 @@ pkgdepends_config <- sort_by_name(list(
# -----------------------------------------------------------------------
windows_archs = list(
type = "string",
default = default_windows_archs,
default = function() default_windows_archs(),
docs =
# we can't indent this "correctly" because markdown will take it as code
"Character scalar specifying which architectures
Expand Down

0 comments on commit ecbb289

Please sign in to comment.