Download packages with their dependencies, from various sources.
Arguments
- refs
Package names or references. See 'Package references' for the syntax.
- ...
Additional arguments, passed to
pkg_download_proposal$new()
.
Details
new_pkg_download_proposal()
creates a new object from the
pkg_download_proposal
class, that can be used to look up and download
R packages and their dependencies. The advantage of
new_pkg_download_proposal()
compared to using the
pkg_download_proposal constructor directly is that it avoids making
pkgdepends a build time dependency.
Typical workflow to download a set of packages:
Create a
pkg_download_proposal
object withnew_pkg_download_proposal()
.Resolve all possible dependencies with
pkg_download_proposal$resolve()
.Download all files with
pkg_download_proposal$download()
.Get the data about the packages and downloads with
pkg_download_proposal$get_downloads()
.
Methods
Method new()
Create a new pkg_download_proposal
object. Consider using
new_pkg_download_proposal()
instead of calling the constructor
directly.
The returned object can be used to look up (recursive) dependencies of R packages from various sources, and then to download the package files.
Usage
pkg_download_proposal$new(refs, config = list(), remote_types = NULL)
Arguments
refs
Package names or references. See 'Package references' for the syntax.
config
Configuration options, a named list. See 'Configuration'.
remote_types
Custom remote ref types, this is for advanced use, and experimental currently.
Examples
pdl <- pkg_download_proposal$new("r-lib/pkgdepends") pdl
Method get_config()
Configuration options for the pkg_download_proposal
object. See
'Configuration' for details.
Returns
Named list. See 'Configuration' for the configuration options.
Method resolve()
Resolve the dependencies of the specified package references. This usually means downloading metadata from CRAN and Bioconductor, unless already cached, and also from GitHub if GitHub refs were included, either directly or indirectly. See 'Dependency resolution' for details.
Method async_resolve()
The same as resolve()
, but asynchronous.
This method is for advanced use.
Method get_resolution()
Query the result of the dependency resolution. This method can be
called after resolve()
has completed.
Returns
A pkg_resolution_result object, which is also a data frame. See 'Dependency resolution' for its columns.
Method download()
Download all resolved packages. It uses the package cache in the pkgcache package by default, to avoid downloads if possible.
Method async_download()
The same as download()
, but asynchronous.
This method is for advanced use.
Method get_downloads()
Returns the summary of the package downloads.
Returns
A pkg_download_result object, which is a list. See pkg_download_result for details.
Method stop_for_download_error()
Throw and error if the some of the downloads have failed for the
most recent
pkg_download_proposal$download()
call.
Method format()
Format a pkg_download_proposal
object, typically for printing.
Method print()
Prints a pkg_download_proposal
object to the screen. The printout
includes:
The package refs.
Whether the object has the resolved dependencies.
Whether the resolution had errors.
Whether the downloads were completed.
Whether the downloads had errors.
Advice on which methods to call next.
See the example below.
Examples
# Method get_refs()
pdl <- new_pkg_download_proposal(c("pak", "jsonlite"))
pdl$get_refs()
#> [1] "pak" "jsonlite"
# Method get_config()
pdl <- new_pkg_download_proposal("pak")
pdl$get_config()
#> # pkg config
#> ## sysreqs_sudo
#> <default>
#> [1] TRUE
#>
#> ## build_vignettes
#> <default>
#> [1] FALSE
#>
#> ## package_cache_dir
#> <default>
#> NULL
#>
#> ## sysreqs_rspm_repo_id
#> <default>
#> [1] "1"
#>
#> ## sysreqs_dry_run
#> <default>
#> [1] FALSE
#>
#> ## metadata_cache_dir
#> <default>
#> [1] "/tmp/Rtmp1EWJjf/file276b7c7c2a4e"
#>
#> ## dependencies
#> <default>
#> [1] "Depends" "Imports" "LinkingTo"
#>
#> ## sysreqs_rspm_url
#> <default>
#> [1] "https://packagemanager.rstudio.com"
#>
#> ## sysreqs
#> <default>
#> [1] TRUE
#>
#> ## platforms
#> <default>
#> [1] "x86_64-pc-linux-gnu-ubuntu-20.04" "source"
#>
#> ## library
#> <default>
#> NULL
#>
#> ## metadata_update_after
#> <default>
#> Time difference of 24 hours
#>
#> ## windows_archs
#> <default>
#> [1] "both"
#>
#> ## cran_mirror
#> <default>
#> CRAN
#> "https://cloud.r-project.org"
#>
#> ## cache_dir
#> <default>
#> [1] "/tmp/Rtmp1EWJjf/file276b2b0d0fa4"
#>
#> ## sysreqs_verbose
#> <default>
#> [1] TRUE
#>
#> ## r_versions
#> <default>
#> [1] "4.1.3"
#>
# Method resolve()
pdl <- new_pkg_download_proposal("pak")
pdl$resolve()
pdl$get_resolution()
#> # A data frame: 2 × 30
#> ref type direct directpkg status package version license
#> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
#> 1 pak standard TRUE TRUE OK pak 0.2.1 GPL-3
#> 2 pak standard TRUE TRUE OK pak 0.2.1 GPL-3
#> # … with 22 more variables: needscompilation <lgl>, priority <chr>,
#> # md5sum <chr>, sha256 <chr>, filesize <int>, built <chr>,
#> # platform <chr>, rversion <chr>, repotype <chr>, repodir <chr>,
#> # target <chr>, deps <list>, mirror <chr>, sources <list>,
#> # remote <list>, error <list>, metadata <list>, extra <list>,
#> # dep_types <list>, params <list>, sysreqs <chr>, cache_status <chr>
# Method get_resolution()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl$resolve()
pdl$get_resolution()
#> # A data frame: 39 × 30
#> ref type direct directpkg status package version license
#> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
#> 1 r-lib/pkgdepends github TRUE TRUE OK pkgdep… 0.3.1.… MIT + …
#> 2 R6 stand… FALSE FALSE OK R6 2.5.1 MIT + …
#> 3 callr stand… FALSE FALSE OK callr 3.7.0 MIT + …
#> 4 cli stand… FALSE FALSE OK cli 3.2.0 MIT + …
#> 5 crayon stand… FALSE FALSE OK crayon 1.5.1 MIT + …
#> 6 curl stand… FALSE FALSE OK curl 4.3.2 MIT + …
#> 7 desc stand… FALSE FALSE OK desc 1.4.1 MIT + …
#> 8 filelock stand… FALSE FALSE OK filelo… 1.0.2 MIT + …
#> 9 glue stand… FALSE FALSE OK glue 1.6.2 MIT + …
#> 10 jsonlite stand… FALSE FALSE OK jsonli… 1.8.0 MIT + …
#> # … with 29 more rows, and 22 more variables: needscompilation <lgl>,
#> # priority <chr>, md5sum <chr>, sha256 <chr>, filesize <int>,
#> # built <chr>, platform <chr>, rversion <chr>, repotype <chr>,
#> # repodir <chr>, target <glue>, deps <list>, mirror <chr>,
#> # sources <list>, remote <list>, error <list>, metadata <list>,
#> # extra <list>, dep_types <list>, params <list>, sysreqs <chr>,
#> # cache_status <chr>
# Method download()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl$resolve()
pdl$download()
#> ℹ Getting 38 pkgs (8.00 MB) and 1 pkg with unknown size
#> ✔ Got crayon 1.5.1 (source) (40.18 kB)
#> ✔ Got callr 3.7.0 (source) (74.52 kB)
#> ✔ Got prettyunits 1.1.1 (source) (10.37 kB)
#> Warning: cannot rename file '/tmp/Rtmp1EWJjf/file276b2b0d0fa4/src/contrib/R6_2.5.1.tar.gz.tmp.1' to '/tmp/Rtmp1EWJjf/file276b2b0d0fa4/src/contrib/R6_2.5.1.tar.gz', reason 'No such file or directory'
#> ✔ Got ps 1.6.0 (source) (119.67 kB)
#> ✔ Got processx 3.5.3 (source) (142.00 kB)
#> ✔ Got filelock 1.0.2 (source) (32.35 kB)
#> ✔ Got R6 2.5.1 (source) (145.73 kB)
#> ✔ Got R6 2.5.1 (source) (145.73 kB)
#> ✔ Got crayon 1.5.1 (source) (156.49 kB)
#> ✔ Got cli 3.2.0 (source) (787.16 kB)
#> ✔ Got desc 1.4.1 (source) (80.67 kB)
#> ✔ Got pkgcache 2.0.1 (source) (223.94 kB)
#> ✔ Got withr 2.5.0 (source) (102.09 kB)
#> ✔ Got filelock 1.0.2 (source) (32.35 kB)
#> ✔ Got rappdirs 0.3.3 (source) (12.29 kB)
#> ✔ Got glue 1.6.2 (source) (157.04 kB)
#> ✔ Got zip 2.2.0 (source) (114.39 kB)
#> ✔ Got desc 1.4.1 (source) (80.67 kB)
#> ✔ Got pkgbuild 1.3.1 (source) (15.55 kB)
#> ✔ Got curl 4.3.2 (source) (1.42 MB)
#> ✔ Got pkgbuild 1.3.1 (source) (15.55 kB)
#> ✔ Got rprojroot 2.0.3 (source) (59.94 kB)
#> ✔ Got callr 3.7.0 (source) (436.19 kB)
#> ✔ Got glue 1.6.2 (source) (106.51 kB)
#> ✔ Got processx 3.5.3 (source) (427.46 kB)
#> ✔ Got curl 4.3.2 (source) (283.88 kB)
#> ✔ Got ps 1.6.0 (source) (363.11 kB)
#> ✔ Got rprojroot 2.0.3 (source) (101.67 kB)
#> ✔ Got prettyunits 1.1.1 (source) (34.36 kB)
#> ✔ Got rappdirs 0.3.3 (source) (47.33 kB)
#> ✔ Got jsonlite 1.8.0 (source) (1.05 MB)
#> ✔ Got lpSolve 5.6.15 (source) (1.04 MB)
#> ✔ Got withr 2.5.0 (source) (226.49 kB)
#> ✔ Got cli 3.2.0 (source) (870.68 kB)
#> ✔ Got zip 2.2.0 (source) (636.99 kB)
#> ✔ Got pkgcache 2.0.1 (source) (794.52 kB)
#> ✔ Got lpSolve 5.6.15 (source) (664.20 kB)
#> ✔ Got jsonlite 1.8.0 (source) (1.16 MB)
#> ✔ Got pkgdepends 0.3.1.9000 (source) (378.40 kB)
pdl$get_downloads()
#> # A data frame: 39 × 35
#> ref type direct directpkg status package version license
#> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
#> 1 r-lib/pkgdepends github TRUE TRUE OK pkgdep… 0.3.1.… MIT + …
#> 2 R6 stand… FALSE FALSE OK R6 2.5.1 MIT + …
#> 3 callr stand… FALSE FALSE OK callr 3.7.0 MIT + …
#> 4 cli stand… FALSE FALSE OK cli 3.2.0 MIT + …
#> 5 crayon stand… FALSE FALSE OK crayon 1.5.1 MIT + …
#> 6 curl stand… FALSE FALSE OK curl 4.3.2 MIT + …
#> 7 desc stand… FALSE FALSE OK desc 1.4.1 MIT + …
#> 8 filelock stand… FALSE FALSE OK filelo… 1.0.2 MIT + …
#> 9 glue stand… FALSE FALSE OK glue 1.6.2 MIT + …
#> 10 jsonlite stand… FALSE FALSE OK jsonli… 1.8.0 MIT + …
#> # … with 29 more rows, and 27 more variables: needscompilation <lgl>,
#> # priority <chr>, md5sum <chr>, sha256 <chr>, filesize <int>,
#> # built <chr>, platform <chr>, rversion <chr>, repotype <chr>,
#> # repodir <chr>, target <glue>, deps <list>, mirror <chr>,
#> # sources <list>, remote <list>, error <list>, metadata <list>,
#> # extra <list>, dep_types <list>, params <list>, sysreqs <chr>,
#> # cache_status <chr>, fulltarget <chr>, fulltarget_tree <chr>, …
# Method get_downloads()
pdl <- new_pkg_download_proposal("pkgload")
pdl$resolve()
pdl$download()
#> ℹ Getting 10 pkgs (2.91 MB), 10 (778.77 kB) cached
#> ✔ Cached copy of R6 2.5.1 (source) is the latest build
#> ✔ Cached copy of cli 3.2.0 (source) is the latest build
#> ✔ Cached copy of cli 3.2.0 (source) is the latest build
#> ✔ Cached copy of R6 2.5.1 (source) is the latest build
#> ✔ Got pkgload 1.2.4 (source) (62.83 kB)
#> ✔ Got rstudioapi 0.13 (source) (110.47 kB)
#> ✔ Got rlang 1.0.2 (source) (741.21 kB)
#> ✔ Got pkgload 1.2.4 (source) (150.28 kB)
#> ✔ Got rstudioapi 0.13 (source) (273.40 kB)
#> ✔ Got rlang 1.0.2 (source) (1.90 MB)
pdl$get_downloads()
#> # A data frame: 20 × 35
#> ref type direct directpkg status package version license
#> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
#> 1 R6 standard FALSE FALSE OK R6 2.5.1 MIT + f…
#> 2 cli standard FALSE FALSE OK cli 3.2.0 MIT + f…
#> 3 crayon standard FALSE FALSE OK crayon 1.5.1 MIT + f…
#> 4 desc standard FALSE FALSE OK desc 1.4.1 MIT + f…
#> 5 glue standard FALSE FALSE OK glue 1.6.2 MIT + f…
#> 6 pkgload standard TRUE TRUE OK pkgload 1.2.4 GPL-3
#> 7 rlang standard FALSE FALSE OK rlang 1.0.2 MIT + f…
#> 8 rprojroot standard FALSE FALSE OK rprojroot 2.0.3 MIT + f…
#> 9 rstudioapi standard FALSE FALSE OK rstudioapi 0.13 MIT + f…
#> 10 withr standard FALSE FALSE OK withr 2.5.0 MIT + f…
#> 11 cli standard FALSE FALSE OK cli 3.2.0 MIT + f…
#> 12 crayon standard FALSE FALSE OK crayon 1.5.1 MIT + f…
#> 13 desc standard FALSE FALSE OK desc 1.4.1 MIT + f…
#> 14 glue standard FALSE FALSE OK glue 1.6.2 MIT + f…
#> 15 pkgload standard TRUE TRUE OK pkgload 1.2.4 GPL-3
#> 16 R6 standard FALSE FALSE OK R6 2.5.1 MIT + f…
#> 17 rlang standard FALSE FALSE OK rlang 1.0.2 MIT + f…
#> 18 rprojroot standard FALSE FALSE OK rprojroot 2.0.3 MIT + f…
#> 19 rstudioapi standard FALSE FALSE OK rstudioapi 0.13 MIT + f…
#> 20 withr standard FALSE FALSE OK withr 2.5.0 MIT + f…
#> # … with 27 more variables: needscompilation <lgl>, priority <chr>,
#> # md5sum <chr>, sha256 <chr>, filesize <int>, built <chr>,
#> # platform <chr>, rversion <chr>, repotype <chr>, repodir <chr>,
#> # target <chr>, deps <list>, mirror <chr>, sources <list>,
#> # remote <list>, error <list>, metadata <list>, extra <list>,
#> # dep_types <list>, params <list>, sysreqs <chr>, cache_status <chr>,
#> # fulltarget <chr>, fulltarget_tree <chr>, download_status <chr>, …
# Method print()
pdl <- new_pkg_download_proposal("r-lib/pkgdepends")
pdl
#> <pkg_download_proposal>
#> + refs:
#> - r-lib/pkgdepends
#> (use `$resolve()` to resolve dependencies)
pdl$resolve()
pdl
#> <pkg_download_proposal>
#> + refs:
#> - r-lib/pkgdepends
#> + has resolution (+19 dependencies)
#> (use `$download()` to download packages)
#> (use `$get_resolution()` to see resolution results)
pdl$download()
#> ℹ Getting 10 pkgs (3.70 MB) and 1 pkg with unknown size, 28 (4.30 MB) cached
#> ✔ Cached copy of pkgdepends 0.3.1.9000 (source) is the latest build
#> ✔ Cached copy of R6 2.5.1 (source) is the latest build
#> ✔ Cached copy of cli 3.2.0 (source) is the latest build
#> ✔ Cached copy of curl 4.3.2 (source) is the latest build
#> ✔ Cached copy of lpSolve 5.6.15 (source) is the latest build
#> ✔ Cached copy of pkgbuild 1.3.1 (source) is the latest build
#> ✔ Cached copy of cli 3.2.0 (source) is the latest build
#> ✔ Cached copy of curl 4.3.2 (source) is the latest build
#> ✔ Cached copy of lpSolve 5.6.15 (source) is the latest build
#> ✔ Cached copy of pkgbuild 1.3.1 (source) is the latest build
#> ✔ Cached copy of R6 2.5.1 (source) is the latest build
pdl
#> <pkg_download_proposal>
#> + refs:
#> - r-lib/pkgdepends
#> + has resolution (+19 dependencies)
#> + has downloads
#> (use `$get_resolution()` to see resolution results)
#> (use `$get_downloads()` to get download data)