Skip to content

[R-pkg-devel] Package dependency graphs of packages in development (local)

9 messages · Gábor Csárdi, Maëlle SALMON, Rainer M Krug

#
Hi

I am quite sure, there was a recent discussion about dependency graphs of packages. I saw the post from Dirk at http://dirk.eddelbuettel.com/blog/2018/02/28/#017_dependencies but `tools::package_dependencies()` does only work on packages on CRAN. 

But my package is not yet on CRAN (but on GitHub and a drat repo), and I would like to look at the package dependencies BEFORE submitting to CRAN.

Is there a tool which allows me to plot a dependency graph for my local package?

Thanks,

Rainer


--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982
#
You can do something like this with https://github.com/r-lib/pkgdepends:

pr <- pkgdepends::remotes()$new("local::.", library = tempfile())
#> ? Creating library directory:
`/var/folders/59/0gkmw1yj2w7bf2dfc3jznv5w0000gn/T//Rtmpo5NL9R/filee95427c73f55`

pr$solve()
#> ? Checking for package metadata updates
#> ? All 10 metadata files are current.
#> ? Using session cached package metadata
#> ? Using cached package metadata
#> PKG SOLUTION, 1 refs, resolved in 1.2s, solved in 193ms
???????????????????????
#>   local::.
#> Dependencies:
#>   github:
#>     r-lib/crancache, r-lib/rcmdcheck
#>   standard:
#>     askpass, assertthat, backports, base64enc, bit, bit64, blob, callr,
#>     cli, clisymbols, cranlike, crayon, curl, DBI, debugme, desc,
#>     digest, evaluate, fansi, glue, gmailr, highr, hms, httr, jsonlite,
#>     knitr, magrittr, markdown, memoise, mime, openssl, parsedate,
#>     pillar, pkgbuild, pkgconfig, prettyunits, processx, progress, ps,
#>     R6, rappdirs, Rcpp, rematch2, remotes, rlang, rprojroot, RSQLite,
#>     sessioninfo, stringi, stringr, sys, tibble, utf8, whoami, withr,
#>     xfun, xopen, yaml

tibble::as_tibble(pr$get_solution()$data)
#> # A tibble: 61 x 27
#>    ref   type  direct status package version license
needscompilation priority
#>    <chr> <chr> <lgl>  <chr>  <chr>   <chr>   <chr>   <lgl>            <chr>
#>  1 loca? local TRUE   OK     revdep? 1.0.0.? MIT + ? NA               NA
#>  2 askp? stan? FALSE  OK     askpass 1.1     NA      FALSE            NA
#>  3 asse? stan? FALSE  OK     assert? 0.2.1   NA      FALSE            NA
#>  4 back? stan? FALSE  OK     backpo? 1.1.4   NA      FALSE            NA
#>  5 base? stan? FALSE  OK     base64? 0.1-3   NA      FALSE            NA
#>  6 bit64 stan? FALSE  OK     bit64   0.9-7   NA      FALSE            NA
#>  7 bit   stan? FALSE  OK     bit     1.1-14  NA      FALSE            NA
#>  8 blob  stan? FALSE  OK     blob    1.1.1   NA      FALSE            NA
#>  9 callr stan? FALSE  OK     callr   3.2.0   NA      FALSE            NA
#> 10 cli   stan? FALSE  OK     cli     1.1.0   NA      FALSE            NA
#> # ? with 51 more rows, and 18 more variables: md5sum <chr>, sha256 <chr>,
#> #   filesize <int>, built <chr>, platform <chr>, rversion <chr>,
repodir <chr>,
#> #   target <chr>, deps <list>, mirror <chr>, sources <list>, remote <list>,
#> #   error <list>, metadata <list>, extra <list>, dep_types <list>,
#> #   cache_status <chr>, lib_status <chr>

And the `deps` column there shows the direct dependencies of the dependencies:

? pr$get_solution()$data$deps[1:2]
#> [[1]]
#> # A tibble: 25 x 5
#>    ref             type    package    op    version
#>    <chr>           <chr>   <chr>      <chr> <chr>
#>  1 assertthat      Imports assertthat ""    ""
#>  2 callr           Imports callr      ""    ""
#>  3 cli             Imports cli        ""    ""
#>  4 clisymbols      Imports clisymbols ""    ""
#>  5 r-lib/crancache Imports crancache  >=    0.0.0.9001
#>  6 crayon          Imports crayon     ""    ""
#>  7 DBI             Imports DBI        ""    ""
#>  8 desc            Imports desc       >=    1.1.1.9002
#>  9 glue            Imports glue       ""    ""
#> 10 gmailr          Imports gmailr     ""    ""
#> # ? with 15 more rows
#>
#> [[2]]
#> # A tibble: 2 x 5
#>   ref      type     package  op    version
#>   <chr>    <chr>    <chr>    <chr> <chr>
#> 1 testthat suggests testthat ""    ""
#> 2 sys      imports  sys      >=    2.1

Gabor
On Thu, May 9, 2019 at 8:53 AM Rainer M Krug <Rainer at krugs.de> wrote:
#
Thanks Gabor. 

This gives me an impressive long list. Is there a way to see this graphically? Parsing seems to be a long, tedious process.

I want to identify packages which I should leave out to reduce the number of (indirect) dependencies.

Rainer
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982
#
Could https://github.com/jimhester/itdepends help?
Ma?lle.
   Den torsdag 9 maj 2019 12:10:14 CEST, Rainer M Krug <Rainer at krugs.de> skrev:  
 
 Thanks Gabor. 

This gives me an impressive long list. Is there a way to see this graphically? Parsing seems to be a long, tedious process.

I want to identify packages which I should leave out to reduce the number of (indirect) dependencies.

Rainer
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:??? +41 (0)44 635 47 64
Cell:? ? ? ??? +41 (0)78 630 66 57
email:? ? ? Rainer.Krug at uzh.ch
??? ??? Rainer at krugs.de
Skype:? ? RMkrug

PGP: 0x0F52F982




??? [[alternative HTML version deleted]]

______________________________________________
R-package-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel
#
Thanks.

This sounds like a really useful package - I?ll check it out.
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982
#
You can try `pr$draw_tree()`, but it is quite buggy, and fails for
infinite (Suggests) loops:
https://github.com/r-lib/pkgdepends/issues/129

This might be an easier way to get the direct dependencies of each
package in the
dependency tree:
tibble::as_tibble(pr$get_install_plan(FALSE))[, c("package", "dependencies")]

Gabor
On Thu, May 9, 2019 at 11:09 AM Rainer M Krug <Rainer at krugs.de> wrote:
#
But I don?t get it to run.

When I do
? Checking for package metadata updates
? Metadata download failed                                                                                                                                 
Error in stop(http_error(resp)) : 
Not Found (HTTP 404).

Could not load or update metadata cache. If you think your local cache is broken, try deleting it with `meta_cache_cleanup()`, or the
`$cleanup()` method.
d> 

I get an error. Suggestions?

Rainer


--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982
#
It fails to download package metadata. Maybe your internet access is
restricted?

Gabor
On Thu, May 9, 2019 at 12:12 PM Rainer M Krug <Rainer at krugs.de> wrote:
#
Nope:

```
? Checking for package metadata updates
? Downloaded metadata files, 1.37 MB in 5 files.                                                                                                           
? Updating metadata database
? Checking for package metadata updates
? Metadata download failed                                                                                                                                 
Error in stop(http_error(resp)) : 
Not Found (HTTP 404).

Could not load or update metadata cache. If you think your local cache is broken, try deleting it with `meta_cache_cleanup()`, or the
`$cleanup()` method.
I can download the cache manually (see above). 

Rainer


```
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Z?rich
Office Y34-J-74
Winterthurerstrasse 190
8075 Z?rich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug at uzh.ch
		Rainer at krugs.de
Skype:     RMkrug

PGP: 0x0F52F982