pkgnet icon indicating copy to clipboard operation
pkgnet copied to clipboard

Add version information to dependency structure

Open jameslamb opened this issue 6 years ago • 5 comments

In R, it is possible to add version floors by specifying something like this in a package's DESCRIPTION file:

Imports:
    data.table (>= 0.10.0)

This information should be added in the labels on nodes in DependencyReporter, so that instead of seeing that a package depends on some_pkg, you can see that it depends on some_pkg (>= some_version).

jameslamb avatar Feb 10 '19 06:02 jameslamb

Hello, I would like to work on this for Hacktoberfest!

zwycl avatar Oct 07 '19 08:10 zwycl

@zwycl That would be much appreciated! Thank you. Please reach out with any questions.

bburns632 avatar Oct 07 '19 16:10 bburns632

Two observations:

  1. I can't find a package_dependencies function variant that would also extract version information. So it seems that I will need to manually extract the versions doing something like deps <- unlist(strsplit(db[package,private$dep_types],",[[:space:]]*")) and strsplit for the second half of the dependency information (the (>= 0.10.0) part)

  2. We also need propagate the version information throughout the recursive_dependencies recursive call for cases when two or more packages share the same dependency package but one package requires a higher version. We should compare and display the higher version on the dependency structure graph.

Please correct me if I am wrong, thanks!

zwycl avatar Oct 08 '19 01:10 zwycl

@zwycl I think this is on the right track. Here are some thoughts.

  1. I would rather avoid string manipulation if possible. Here's what I could find that might be helpful as something to build upon. It hinges on reading DESCRIPTION as a yml file, which seems more direct, but I am also not sure if it is the best approach as these files are truly in DCF, the Debian control format.
t <- yaml::read_yaml(file = '~/repos/pkgnet/DESCRIPTION')
t2 <- c(t[['Imports']], t[['Depends']])
t3 <- devtools::parse_deps(t2)
t3

image

  1. In that scenario, I think that's a reasonable default. In practice, I think if an R package had two different dependencies on the same package with mutually exclusive version numbers (e.g. <=1.5.0 and >=1.7.0), it would fail during package build b/c R cannot maintain two different versions of the same package.

bburns632 avatar Oct 08 '19 14:10 bburns632

To be fair, devtools::parse_deps() is just doing string manipulation (pretty close to what you described above), but at least it is a stable and well maintained string parsing process. If things changed in R, it would be updated quickly.

image

bburns632 avatar Oct 08 '19 14:10 bburns632