-
Notifications
You must be signed in to change notification settings - Fork 431
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
Support renaming dependencies in rust_library and rust_binary #171
Comments
Worth mentioning that bazel users can still include |
I actually wasn't aware of this. I've done some digging to figure out what the actual policy is, but my tl;dr is to punt on this unless a new RFC suggests deprecation of The RFC for the feature is available here: https://github.com/rust-lang/rfcs/blob/master/text/2126-path-clarity.md. It has some inconclusive verbiage around deprecation of the old syntax
... but the most definitive statement of effect is just this
Indicating that the strongest "deprecation" prescribed by this RFC is just a warn-by-default lint. I guess we need to keep an eye out for anything stronger in the future From the reference, we only have this
|
Ok well, I now have an addendum. Out of an abundance of caution, I dropped into mozilla/#rust to see if anyone knew of an explicit initiative to deprecate. Lo and behold: rust-lang/rust#53128 Choice quotes (emphasis mine):
Somehow between the actual paths rfc and that issue the idea of "deprecating |
What is the use case for aliasing crates? I have never seen this, though
I've seen it as a convenience in Python numpy)pandas code.
I am happy to punt until there's an issue.
…On Tue, Dec 11, 2018, 13:38 Alex McArther ***@***.***> wrote:
Ok well, I now have an addendum.
Out of an abudance of caution, I dropped into mozilla/#rust to see if
anyone knew of an explicit initiative to deprecate. Lo and behold:
rust-lang/rust#53128 <rust-lang/rust#53128>
Somehow between the actual paths rfc and that issue the idea of
"deprecating extern crate" became the understanding. I don't think we can
punt on this for an extended duration for that reason.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#171 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACLjeBOxPc2JOJxaHelzyedE63xhhP14ks5u3_ubgaJpZM4ZMelz>
.
|
I only have toy scenarios for this, one of which doesn't even benefit from the feature in hindsight. Anyway, here they are: Consider a Scenario 1: Consider some cases where there are two Scenario 2: Consider a situation where, for whatever crazy reason, Crate So.. Those are all pretty weak. Lets consult Alex Crichton, in rust-lang/cargo@79942fe which originally added the feature in Cargo, (emphasis mine):
|
First of all sorry to bump an old tread, but I think I have just encountered a situation that this issue refers to. I am trying to get new futures 0.3 to compile together with cargo-raze. I am encountering an annoying problem, which I think touches on this thread to enable to rename dependencies. Futures 0.3 with I would love instead of recompile the whole futures-0.1.29 crate as futures_01 to just import it into futures-0.3.1 as a rename. Would this represent a valid case for this feature, or am I missing something very simple? I can provide a simple repo that shows this problem. |
I just ran into the same exact issue with futures compat. I implemented something very similar to what @acmcarther described: rust_library(
...
renamed_deps = {
"@third_party__futures__0_1_29//:futures": "futures_01"
},
) It wasn't that hard to implement (<25 lines), but I'm not sure how much refactoring I'd need to do to get it mergeable. Right now I re-create Instead, I've been thinking about a different approach: a rust_aliased_crate(
name = "futures_01",
crate = "@third_party__futures__0_1_29//:futures"
) We'd probably also need an optional rust_aliased_crate(
name = "__cargo_renamed__futures_01",
crate_name = "futures_01",
crate = "@third_party__futures__0_1_29//:futures"
) This would let
rust_library(
name = "futures_util",
deps = [
":__cargo_renamed__futures_01",
...
],
...
)
rust_aliased_crate(
name = "__cargo_renamed__futures_01",
crate_name = "futures_01",
crate = "@third_party__futures__0_1_29//:futures",
visibility = ["//visibility:private"]
) This would also support renaming in the root We could also include two "foo" crates which are independently renamed to something else: rust_library(
name = "foo",
deps = [
":bar",
":baz"
],
)
rust_aliased_crate(
name = "bar",
crate = "//:foo"
)
rust_aliased_crate(
name = "baz",
crate = "//another:foo"
) What do you think @acmcarther @mfarrugi @Sythanis? Am I missing something? |
@Sythanis, @kornholi Apologies on the delay getting back to the both of you. I think @kornholi 's suggestion makes sense and seems like what I had in mind a year ago and I think merging such a change would make sense. Between "rust_library.renamed_deps" and a new "rust_aliased_crate", I think my preference would be for the former, regardless of how janky the implementation is. My rationale is that, afaict, a user could implement "rust_aliased_crate" in their own Bazel workspace, but they could not implement "renamed_deps" without forking and changing rules_rust. I also think "renamed_deps" is somewhat closer to the semantics of the analogous Cargo feature. I don't feel strongly about the above though and I think a PR containing either approach could make sense to merge. |
A similar approach has been implemented in #285 |
With the "2018" edition, Rust library and binary root source files no longer include
extern crate
statements. This removes the original mechanism by which an external crate dependency can be renamed.Cargo has implemented dependency renaming. This feature first appeared in this commit:
rust-lang/cargo@79942fe. In the most recent implementation (as of time of writing) this field is renamed multiple times before entering the link_to function where linking actually happens.
I suspect our only real option here will be to add a param "rename_deps" (bikeshed welcome) that maps from string -> string:
EDIT: 2018-12-11 ~11:00PST:
"rename_deps" is not equivalent to the Cargo implementation. Cargo implements this via a field on the dependency itself, meaning that it is theoretically possible to use this feature to include two "foo" crates which are independently renamed to something else. I have no idea how we'd replicate this while following the
rust_library.deps
convention...The text was updated successfully, but these errors were encountered: