-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matching Package
or NodeDep
to Dependency
#84
Comments
Package
or NodeDep
sPackage
or NodeDep
to Dependency
I do not know. This crate only exposes the information from |
You cannot (easily) go from a Dependency to a Package. That involves Cargo's resolver, which discards the Dependency information once it is resolved to a package. Your example workaround would also need to handle matching versionreq specifiers against version strings, for example (since there could be multiple matches). The name in Can you explain more about why you want to match them? |
@ehuss I want to generate a transitive list of normal dependencies (excluding build/development dependencies, information that is stored in |
Unfortunately I don't see a way to reliably do that with the current information. This is essentially rust-lang/cargo#5583 and rust-lang/cargo#4631. I have created a PR to try to address this: rust-lang/cargo#7132. I'd appreciate it if you can take a look at it and provide feedback if it would work. I'm not familiar with cargo-license, but I would suspect it would run |
From looking at it, it doesn't seem to look at |
Right. If you want to filter based on kind, you would need to change it to traverse the resolve graph, filtering based on kind. |
Exactly, which is what I was attempting to do, but then failed at the point of matching the different representations due to the lack of package ID, leading to this PR. |
It is still very difficult to correlate the resolve nodes with the package dependencies, but with #91, you can now detect the dependency kind (normal/build/devel) within the resolve graph. |
There's a higher level wrapper around |
Closing as out of scope |
While the
Package
contains a list of direct dependencies, how can I match aDependency
to a correspondingPackage
? I initially considered usingNodeDep
which contains aPackageId
, but the names inNodeDep
do not always match the names inDependency
(even if considering renames).For example:
backtrace
's list ofNodeDep
s contains"backtrace_sys"
, while it's list ofDependency
s contains only"backtrace-sys"
and rename isNone
.This could also be a bug/issue with
cargo metadata
itself, or I'm just using it incorrectly - especially since the lengths of the two lists often don't match.My current workaround (which feels quite hacky, but works so far), where
root_node
is aNode
androot_package
is the correspondingPackage
:The text was updated successfully, but these errors were encountered: