Gabriel and Simon
I completely agree with what you are saying.
The thing is that obtaining recursive deps, all/most whatever, is already
well supported in core R. What is missing is just this single functionality
I am requesting.
If you will look into the branch you can see there is mirror.packages
function meant to mirror a slice of CRAN. It is doing exactly what you
described: package_dependencies; to obtain recursive deps, then download
all, etc.
I would love to have this function provided by core R as well, but we need
to start somewhere.
There are other use cases as well.
For example CI, where one wants to install all/most dependencies and then
run R CMD check. Then we don't worry about recursive deps are they will be
resolved automatically.
I don't think it's reasonable to force users to use 3rd party packages to
handle such a common and simple use case. Otherwise one has to hard code
deps in CI script. Not robust at all.
packages.dcf and repos.dcf makes all that way easier, and are solid base
for building customized orchestration like mirroring slice of CRAN.
Best regards
Jan
On Sun, Oct 16, 2022, 01:31 Simon Urbanek
wrote:
> Jan,
>
> I think using a single DCF as input is not very practical and would not be
> useful in the context you describe (creating self contained repos) since
> they typically concern a list of packages, but essentially splitting out
> the part of install.packages() which determines which files will be pulled
> from where would be very useful as it would be trivial to use it to create
> repository (what we always do in corporate environments) instead of
> installing the packages. I suspect that install packages is already too
> complex so instead of adding a flag to install.packages one could move that
> functionality into a separate function - we all do that constantly for the
> sites we manage, so it would be certainly something worthwhile.
>
> Cheers,
> Simon
>
>
> > On Oct 15, 2022, at 7:14 PM, Jan Gorecki wrote:
> >
> > Hi Gabriel,
> >
> > It's very nice usage you provided here. Maybe instead of adding new
> > function we could extend packages_depenedncies then? To accept file path
> to
> > dsc file.
> >
> > What about repos.dcf? Maybe additional repositories could be an attribute
> > attached to returned character vector.
> >
> > The use case is to, for a given package sources, obtain its dependencies,
> > so one can use that for installing them/mirroring CRAN subset, or
> whatever.
> > The later is especially important for a production environment where one
> > wants to have fixed version of packages, and mirroring relevant subset of
> > CRAN is the most simple, and IMO reliable, way to manage such
> environment.
> >
> > Regards
> > Jan
> >
> > On Fri, Oct 14, 2022, 23:34 Gabriel Becker
> wrote:
> >
> >> Hi Jan and Jan,
> >>
> >> Can you explain a little more what exactly you want the non-recursive,
> >> non-version aware dependencies from an individual package for?
> >>
> >> Either way package_dependencies will do this for you* with a little
> >> "aggressive convincing". It wants output from available.packages, but
> who
> >> really cares what it wants? It's a function and we are people :)
> >>
> >>> library(tools)
> >>> db <- read.dcf("~/gabe/checkedout/rtables_clean/DESCRIPTION")
> >>> package_dependencies("rtables", db, which = intersect(c("Depends",
> >> "Suggests", "Imports", "LinkingTo"), colnames(db)))
> >> $rtables
> >> [1] "methods""magrittr" "formatters" "dplyr" "tibble"
> >> [6] "tidyr" "testthat" "xml2" "knitr" "rmarkdown"
> >> [11] "flextable" "officer""stats" "htmltools" "grid"
> >>
> >>
> >> The only gotcha that I see immediately is that "LinkingTo" isn't always
> >> there (whereas it is with real output from available.packages). If you
> >> know your package doesn't have that (or that it does) at call time ,
> this
> >> becomes a one-liner:
> >>
> >> package_dependencies("rtables", db =
> >> read.dcf("~/gabe/checkedout/rtables_clean/DESCRIPTION"), which =
> >> c("Depends", "Suggests", "Imports"))
> >> $rtables
> >> [1] "methods""magrittr" "formatters" "dplyr" "tibble"
> >> [6] "tidyr" "testthat" "xml2" "knitr" "rmarkdown"
> >> [11] "flextable" "officer""stats" "htmltools" "grid"
> >>
> >> You can also trick it a slightly different way by giving it what it
> >> actually wants
> >>
> >>> tdir <- tempdir()
> >>> file.copy("~/gabe/checkedout/rtables_clean/DESCRIPTION",
> file.path(tdir,
> >> "PACKAGES"))
> >> [1] TRUE
> >>> avl <- available.packages(paste0("file://", tdir))
> >>> library(tools)
> >>> package_dependencies("rtables", avl)
> >> $rtables
> >> [1] "methods""magrittr" "formatters" "stats" "htmltools"
> >> [6] "grid"
> >>
> >>> package_dependencies("rtables", avl, which = "all")
> >> $rtables
> >> [1] "methods""magrittr" "formatters" "stats" "htmltools"
> >> [6] "grid" "dplyr" "tibble" "tidyr" "testthat"
> >> [11] "xml