-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Workspace inheritance #6089
Workspace inheritance #6089
Conversation
Co-authored-by: Tristan Guichaoua <33934311+tguichaoua@users.noreply.github.com>
job "check-missing-examples-in-docs" is missing rust update. |
What about the other dependencies, like |
So, I'd like to specify a single workspace level version to use. Does including them at the workspace level still let us build the constituent crates without these optional dependencies? EDIT: looks like the answer is no :(
https://doc.rust-lang.org/cargo/reference/workspaces.html#the-dependencies-table I suspect we should leave at this for now, rather than shipping pointless dependencies to users of the smaller crates. |
Let's try like this for now, and maybe check later for those. not convinced it would improve a lot This PR also probably remove the need for https://github.com/bevyengine/bevy/blob/main/.github/workflows/release.yml and https://github.com/bevyengine/bevy/blob/main/.github/workflows/post-release.yml which were there to help with the version updates across all crates. @cart do you have an opinion on keeping the auto workflows (that does not support yet workspace inheritance - crate-ci/cargo-release#499) |
I just assumed that u can not set the optional at the workspace level, but u can still set it in the specific dependencies sections of the child creates. Edit: |
Yes, this is actually possible, there is an example here [project]
name = "bar"
version = "0.2.0"
[dependencies]
regex = { workspace = true, features = ["unicode"] }
[build-dependencies]
cc.workspace = true
[dev-dependencies]
rand = { workspace = true, optional = true } Important point : crate level |
So for these one with the default features disabled we have to stick to the old syntax? So i need to revert the changes where the default features are disabled, right?
should use the old syntax
|
Since Also, I think we should first establish rules for when using workspace dependencies or not. |
This was just an example for one dependency with default features, there are more of them, which are used at more places (e. g.
So should i just revert the |
I will just do that and resolve the merge conflicts, that we can close this |
This pr only inculdes the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Could you also add the This PR would break the workflows |
Any ideas why this action failed before and now it just passed? |
Flaky test :( There's an open issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for most crates, we could also inherit the keywords.
No, the graphics keyword doesn't apply to most crates. |
I am not saying we should inherit all of them as they currently are defined for the parent crate. A minimum of |
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
|
Cargo.toml
Outdated
@@ -23,6 +10,26 @@ members = [ | |||
"errors", | |||
] | |||
|
|||
[workspace.package] | |||
version = "0.9.0-dev" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version = "0.9.0-dev" | |
version = "0.10.0-dev" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if we should bump the version in this pull request, in my opinion we should do this in another pr?
If we do, we also need to update all the dependencies, because the version of the dependencies is not inherited at the moment (see conversation above).
I guess their is an GitHub-Action for that?
I'd like to hear some arguments for using workspace inheritance for "bevy_x crate version numbers", as right now I'm seeing a number of downsides and no upsides:
|
I think you can still use workspace dependencies that are optional, you just declare them as optional at the crate level not at the workspace level. (Sorry if I misunderstood and you already knew that) Example:./Cargo.toml [dependencies]
# Root bevy crate optional dep
bevy_dylib = { workspace = true, optional = true}
[workspace.dependencies]
# Can't use optional here, the crates choose that individually
bevy_dylib = { path = "crates/bevy_dylib", version = "0.9.0", default-features = false }
bevy_math = { path = "crates/bevy_math", version = "0.9.0" } ./bevy_reflect/Cargo.toml [dependencies]
# bevy_x crate with optional dep from workspace
bevy_math = { workspace = true, version = "0.9.0", features = ["serialize"], optional = true } |
I would agree that the version number inheritance is not beneficial for us at the moment, since we can't use the dependency inheritance as we would like to. There is an open issue/pull-request at the cargo repository about the problem, that you can only use the default features for all or for none packages, if the package inherits the workspace package. If the cargo/rust community decides to allow at least to disable default-features on the workspace level and then enable it at the child, we could use the dependency inheritance. I think this could be possible since in the current rfc (https://rust-lang.github.io/rfcs/2906-cargo-workspace-deduplicate.html) it's not allowed to define the default feature in the package level (but there is no error/warning if you define it anyway, it is just not working if you do so), so it shouldn't be a breaking change. Then at least we could use the following: [workspace.dependencies]
foo = { version = "0.1.0", default-features = false}
[dependencies]
foo = { workspace = true, default-features = true } |
Ah I wasn't aware of this. That does change things. Does that mean that if a "workspace dependency" is not referenced by a crate anywhere in the workspace, it won't actually be built? |
Hmm, that's what I had thought from reading the docs but I just tried it and I was able to use a dependency from the workspace without specifying it in the child library's cargo.toml at all so I guess I was wrong. Seems less useful than I was originally thinking. |
I'm going to close this out then. If there's a strong reason found I'm happy to try again! |
Objective
Solution