Skip to content
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

rerun_py always enables all of rerun's default-flags #2024

Closed
teh-cmc opened this issue May 2, 2023 · 4 comments · Fixed by #2026
Closed

rerun_py always enables all of rerun's default-flags #2024

teh-cmc opened this issue May 2, 2023 · 4 comments · Fixed by #2026
Labels
dependencies concerning crates, pip packages etc 🐍 Python API Python logging API

Comments

@teh-cmc
Copy link
Member

teh-cmc commented May 2, 2023

rerun_py imports rerun like this:

rerun = { workspace = true, default-features = false, features = [
  "analytics",
  "server",
  "sdk",
] }

So you'd think you wouldn't get a viewer with that, right? Wrong:

$ cargo tree --no-default-features -i re_viewer

re_viewer v0.6.0-alpha.0 (/home/cmc/dev/rerun-io/rerun/crates/re_viewer)
└── rerun v0.6.0-alpha.0 (/home/cmc/dev/rerun-io/rerun/crates/rerun)
    └── rerun_py v0.6.0-alpha.0 (/home/cmc/dev/rerun-io/rerun/rerun_py)

The reason is because rerun default features are declared as:

[features]
default = ["analytics", "glam", "image", "native_viewer", "server", "sdk"]

and then rerun is advertised to the workspace as:

rerun = { path = "crates/rerun", version = "=0.6.0-alpha.0" }

which implies defaults-features = true, and cannot be overridden since features are implicitly additive!!!!

(Note: starting with Rust 1.69, the current setup actually yields a (pretty cryptic) warning: rerun-io/rerun/rerun_py/Cargo.toml: default-features is ignored for rerun, since default-features was not specified for workspace.dependencies.rerun, this could become a hard error in the future)

Now the issue is that we definitely don't want to change those default features, as they are in fact the correct defaults for anyone importing the main library (including our official Rust examples!).

If the advertised rerun feature flags at the workspace level only impact usage from within the workspace, then one possible solution is to set default-features = false at the workspace level, and make the examples import the release crate instead?

@teh-cmc teh-cmc added 🐍 Python API Python logging API dependencies concerning crates, pip packages etc labels May 2, 2023
@teh-cmc teh-cmc linked a pull request May 2, 2023 that will close this issue
2 tasks
@teh-cmc teh-cmc removed a link to a pull request May 2, 2023
2 tasks
@teh-cmc
Copy link
Member Author

teh-cmc commented May 2, 2023

Can confirm that the root manifest does not apply when importing the crates from an external project.

E.g. setting up a simple project with the following manifest:

[package]
name = "test"
version = "0.1.0"
edition = "2021"

[dependencies]
rerun = { version = "0.5.0", default-features = false }

yields

$ cargo tree -i re_viewer
error: package ID specification `re_viewer` did not match any packages

I.e. there is an opportunity here to define default feature sets for internal vs. external use.

@emilk
Copy link
Member

emilk commented May 2, 2023

Let's start by banning workspace dependencies from our examples, as they should be copy-pastable. They should still use path = { … } though, i.e. use the crate in the repository; not the latest published crate imho (otherwise development would gain no use of the examples)

@teh-cmc
Copy link
Member Author

teh-cmc commented May 3, 2023

Let's start by banning workspace dependencies from our examples, as they should be copy-pastable. They should still use path = { … } though, i.e. use the crate in the repository; not the latest published crate imho (otherwise development would gain no use of the examples)

Then they are back to not being copy-pastable though 😕

Maybe we could have the examples depend on the non-released alpha tag (0.6.0-alpha.0 atm), and then add all of the workspace crates to the [path.crates-io] section (edit: no idea how that would behave with crate release rules though...).

Then the examples become fully copy-pastable, at least if you're copying them from a commit/branch/tag that has already been released to crates.io.

@teh-cmc
Copy link
Member Author

teh-cmc commented May 3, 2023

Played with it a little more, and basically the problem is that the workspace override rules only apply to direct dependencies.

E.g. say you are in an example and import rerun as:

[dependencies]
rerun = { path = "../../../crates/rerun", features = ["web_viewer"] }

since you're going through a path, the workspace definition of rerun feature flags doesn't apply but rather the defaults defined directly in rerun/Cargo.toml do.

That's great, but then rerun imports re_sdk as re_sdk.workspace = true, and so the default feature flags used for this indirect dependency are those defined in the root manifest... which makes things extremely confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies concerning crates, pip packages etc 🐍 Python API Python logging API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants