-
Notifications
You must be signed in to change notification settings - Fork 105
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
Generate //cargo:cargo.bzl during WORKSPACE #8
Comments
I had considered this possibility, but wasn't satisfied that it was easy enough to make the cargo-raze binary available without
Actually, the exact named directories are not visible outside of the //cargo directory. Users are expected to access their external Cargo dependencies via the aliases declared in //cargo:BUILD, which only export declared dependencies (not transitives) similar to how Cargo does this. Those labels are not explicitly versioned. That said, this mechanism is very interesting, and might enable per-target dependency specification which is interesting in its own right. I'll read through how this is being done in rules_python in greater detail. |
Ah one more nuance: If i understand the rules_python implementation, multiple versions of transitive dependencies are not supported. This is suboptimal for the EDIT: Added "internally" after "sufficient" as in "not sufficient internally", to distinguish from what is exported in the alias file. |
That's interesting, I hadn't realized that any language but Node.js was doing that. TIL :) |
Having both
Cargo.toml
and//cargo:crates.bzl
checked in forks the source of truth in undesirable ways. There is a trick thatrules_python
is using to avoid this split, which would enable Bazel to directly consumeCargo.toml
(or preferablyCargo.lock
).The pattern is effectively a two-phase load:
This is basically identical to what you are doing, but avoids checking in
crates.bzl
by running it duringWORKSPACE
iffCargo.lock
changes (no more forking the source of truth!).I also notice that this generates repository names containing exact versions, which could lead to significant churn when dependencies update (e.g. update toml => lock). The way
rules_python
addresses this is by generating a function inthe_repo_name
calledrequirement()
that maps the requirement's name to thepy_library
we generate for it. This enablesBUILD
files to avoid the versioned dependency names (see example).The text was updated successfully, but these errors were encountered: