-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
Make rand dependency optional #604
Conversation
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 the offending rand_hc
release has already been yanked, but I like the idea of this anyway because I often write medium-sized utility libraries that use nalgebra and have no business depending on rand, and a quicker build/smaller dep graph is always welcome.
Cargo.toml
Outdated
optional = true | ||
default-features = false | ||
features = [ "stdweb" ] | ||
|
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.
Do we have tests confirming that this section works as expected, in both positive and negative cases?
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've tested it by hand, but I'll look into if we can do this in the CI.
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.
So looking into it a bit more, looks like neither of the conditional sections here were actually getting activated. I don't think it's possible to pass feature flags to optional dependencies without activating the dependency. The only solution seems to be to provide new features "std-no-rand" and "stdweb-no-rand". As a sidenote, while investigating this, I noticed that the "stdweb" feature is currently broken in master.
Note that it's semver compatible to make breaking changes pre 1.0 in minor versions. |
See Point 4
|
Note that rust-random/rand#818 was a release issue resolved within a two-hour window (the breaking part within half an hour IIRC), so it hardly seems fair to use as motivation here. The other reports appear to relate to version 0.6.5, which, yes, causes issues for those doing selective updates from previous versions. That said, I don't object to the idea of making the dependency optional, though I don't believe there remains a big motivation ( What I do find strange is this Maybe it would be best to update to |
I only know that I've had my builds break twice now within a few months of each other just because rand pushed out a new version. I think it's entirely fair to not want to use a crate that behaves in this manner. That aside, I think it's a good change to make this crate optional, as I would imagine quite a large portion of the users of nalgebra aren't interested in the random number generation aspects, and removing any additional dependencies will improve compile times for users. I'm not particularly happy with how the features turned out here. I don't remember what exactly was the problem, but it's a weird quirk of the |
I would prefer rand to be optional in So we would want the random functionality simply to not be available when compiling instead |
@repi the rand lib does also support deterministic generation (using fixed seeds). It can even come without support for any system calls if default features are disabled. However this is all irrelevant if you have no need for pseudo-random values. |
Yes I should have been more precise, it is the optional but default
Though still think it would be nice to have a stronger way to disable the support explicitly like with this suggested PR feature toggle, but is at least less of an issue for us if it already doesn't bring in the OS functions |
Using |
@aleksijuvani |
Sure, that seems fine. I would prefer rand to be opt-in in the first place, and if it allows us to avoid the awkward "std-no-rand" feature flag, that's good. Not sure if it makes sense to bundle into the same pull request as #622 however, as it's essentially a different issue. |
@sebcrozet What are your thoughts on this whole rand situation? |
I'm in favor of making the dependency to I'm closing this PR because it does not seem to bring anything more than what #622 already covers, but feel free to reopen and correct me if I am wrong. Thank you @aleksijuvani for preparing this PR anyway. |
In the light of the rand crate pushing semver-incompatible changes (again) and breaking every (even indirectly) dependent crate, this pull request makes the rand dependency in nalgebra optional. See issues rust-random/rand#818, rust-random/rand#645, rust-random/rand#766, rust-random/rand#754.
Frankly, I'm tired of dealing with this and I would suggest removing the rand crate from the default features outright, but this would be a breaking change, and I'm not sure how to structure
Cargo.toml
so that the tests can still enable this feature.