Add version information to dependency structure
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).
Hello, I would like to work on this for Hacktoberfest!
@zwycl That would be much appreciated! Thank you. Please reach out with any questions.
Two observations:
-
I can't find a
package_dependenciesfunction variant that would also extract version information. So it seems that I will need to manually extract the versions doing something likedeps <- unlist(strsplit(db[package,private$dep_types],",[[:space:]]*"))and strsplit for the second half of the dependency information (the(>= 0.10.0)part) -
We also need propagate the version information throughout the
recursive_dependenciesrecursive 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 I think this is on the right track. Here are some thoughts.
- 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

- 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.
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.
