-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provide exported functions for interacting with lockfiles #1438
Changes from all commits
b6eda2a
4bc5c16
97e46e6
02a5431
ae1e952
fb91b74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,86 @@ | |
#' Note that the `Name` field may be empty. In that case, a project-local Python | ||
#' environment will be used instead (when not directly using a system copy of Python). | ||
#' | ||
#' # Caveats | ||
#' | ||
#' These functions are primarily intended for expert users -- in most cases, | ||
#' [snapshot()] and [restore()] are the primariy tools you will need when | ||
#' creating and using lockfiles. | ||
#' | ||
#' @inheritParams snapshot | ||
#' @inheritParams renv-params | ||
#' | ||
#' @param lockfile An `renv` lockfile; typically created by either | ||
#' `lockfile_create()` or `lockfile_read()`. | ||
#' | ||
#' @param file A file path, or \R connection. | ||
#' | ||
#' @family reproducibility | ||
#' @name lockfiles | ||
#' @rdname lockfiles | ||
#' @name lockfile | ||
#' @rdname lockfile | ||
NULL | ||
|
||
#' @param libpaths The library paths to be used when generating the lockfile. | ||
#' @rdname lockfile | ||
#' @export | ||
lockfile_create <- function(type = settings$snapshot.type(project = project), | ||
libpaths = .libPaths(), | ||
packages = NULL, | ||
exclude = NULL, | ||
..., | ||
project = NULL) | ||
{ | ||
project <- renv_project_resolve(project) | ||
|
||
renv_lockfile_create( | ||
project = project, | ||
libpaths = libpaths, | ||
type = type, | ||
packages = packages, | ||
exclude = exclude | ||
) | ||
} | ||
|
||
#' @rdname lockfile | ||
#' @export | ||
lockfile_read <- function(file = NULL, ..., project = NULL) { | ||
project <- renv_project_resolve(project) | ||
file <- file %||% renv_paths_lockfile(project = project) | ||
renv_lockfile_read(file = file) | ||
} | ||
|
||
#' @rdname lockfile | ||
#' @export | ||
lockfile_write <- function(lockfile, file = NULL, ..., project = NULL) { | ||
project <- renv_project_resolve(project) | ||
file <- file %||% renv_paths_lockfile(project = project) | ||
renv_lockfile_write(lockfile, file = file) | ||
} | ||
|
||
#' @param remotes A named \R list, mapping package names to the remote | ||
#' specifications to be recorded in the lockfile. | ||
#' | ||
#' @param repos A named vector, mapping \R repository names to their URLs. | ||
#' | ||
#' @rdname lockfile | ||
#' @export | ||
lockfile_modify <- function(lockfile, | ||
..., | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not used internally, but I thought this might be useful for end users (e.g. a way to explicitly set the repositories in a lockfile) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I meant the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh sorry. That's there intentionally so we can:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (but maybe I should add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think if you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok; I made that change on main. |
||
remotes = NULL, | ||
repos = NULL) | ||
{ | ||
if (!is.null(repos)) { | ||
lockfile$R$Repositories <- as.list(repos) | ||
} | ||
|
||
if (!is.null(remotes)) { | ||
remotes <- renv_records_resolve(remotes) | ||
enumerate(remotes, function(package, remote) { | ||
record <- renv_remotes_resolve(remote) | ||
renv_lockfile_records(lockfile)[[package]] <<- record | ||
}) | ||
} | ||
|
||
lockfile | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,7 +416,7 @@ local({ | |
on.exit(do.call(base::options, saved), add = TRUE) | ||
} | ||
|
||
catf("* Downloading from GitHub ... ", appendLF = FALSE) | ||
catf("* Downloading version %s from GitHub ... ", version, appendLF = FALSE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spurious diff? |
||
|
||
url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) | ||
name <- sprintf("renv_%s.tar.gz", version) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest adding a "for expert use only" caution somewhere.