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

Make rand dependency optional #483

Merged
merged 3 commits into from
May 3, 2019
Merged

Make rand dependency optional #483

merged 3 commits into from
May 3, 2019

Conversation

LukasKalbertodt
Copy link
Contributor

Closes #481

This PR leaves the feature enabled by default so that this can be released as a minor version soon. (I would suggest to disable it by default in future versions, but that's another discussion.)

The changes are pretty straight forward with one catch: I changed some use statements to nested imports (otherwise, there would be even more #[cfg(feature = "rand")] lines). Nested imports were stabilized in 1.25 (see the edition guide on this feature). I'm not sure how cgmaths policy on minimum compiler version is. Maybe cgmath already requires a >= 1.25 compiler for other reasons. If my change is a problem, just tell me and I will change the imports back.

Most users probably don't use the rand impls, so the `rand` crate pulls
a large number of dependencies into the dependency tree which is just
wasted compilation time.
@kvark
Copy link
Collaborator

kvark commented May 2, 2019

Looks fine by me overall.
Is non-rand case being tested by CI?

Leaving for others to have a look as well.

@LukasKalbertodt
Copy link
Contributor Author

Is non-rand case being tested by CI?

No, currently not.

We probably would like to have a test case without any optional features (without rand, serde and mint) and one with all enabled? Testing all permutations (times two because of beta/stable) is probably overkill. Shall I change the CI configuration as described?

@kvark
Copy link
Collaborator

kvark commented May 2, 2019

Just doing cargo test --no-default-features would be fine by me.

@LukasKalbertodt
Copy link
Contributor Author

LukasKalbertodt commented May 2, 2019

@kvark I just pushed a commit. I hope this is what you had in mind. The cargo bench command does not have the --no-default-features flag, because the benchmark require the rand impls.

The two nightly failures don't have anything to do with this change.

.travis.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can publish this as a patch so easily. It would break anyone who depends on cgmath with no default features...
Otherwise, I agree that we should not have it by default in future versions.

.travis.yml Outdated Show resolved Hide resolved
@LukasKalbertodt
Copy link
Contributor Author

anyone who depends on cgmath with no default features...

As cgmath didn't offer any default features before, I doubt many people use cgmath in that configuration. Furthermore RFC 1105 (which defines which changes are considered "major changes"), states that "Altering the use of Cargo features" is a minor change.

@kvark
Copy link
Collaborator

kvark commented May 3, 2019

@LukasKalbertodt thank you for the link! Upon reading it carefully, I don't think it applies to our case. It's more about what features of dependent projects our project decides to enable. For example, we depend on serde with serde_derive feature enabled. If we were to change that list of required serde features in any way (what is referred to as "altering"), that wouldn't be a breaking change. However, changing the default features of self is a breaking change.

@LukasKalbertodt
Copy link
Contributor Author

LukasKalbertodt commented May 3, 2019

@kvark Might be true 🤔

I guess you don't plan on releasing a major new version of cgmath anytime soon? If not, I would probably need to use a fork until it is released. That wouldn't be a huge problem, but still unfortunate.

And regarding this PR: can this be merged regardless of its breaking-nature? Or should I create a new PR against a different branch?

@kvark
Copy link
Collaborator

kvark commented May 3, 2019

@ozkriff @tomaka @brendanzab @csherratt @torkleyy

I was about to say that I'm not intimately familiar with cgmath workflow and release procedures, and that we should ask somebody else, but then I scanned the history of merged PRs and mostly saw myself lately :( yikes! I hope I'm not the last holdout of cgmath, since my focus is graphics anyway, and I just want the ecosystem to be healthy.

Anyhow, in other projects I have, the master is always one receiving breaking changes like this, while post-release patches go into release branches. I don't see any such branches here, but at least I see the release tags. So do I understand correctly that this project prefers a branch spawned from a release tag, merged, published, and a new tag produced, while the branch gets removed?

@LukasKalbertodt typically, releasing a breaking version upon seeing the first breaking change would waste a lot of effort by the community in updating... (unless they rely on mint). So what I do is - scanning the list of issues and looking for other breaking changes that we accepted and haven't got merged/implemented yet. This is work, and I don't expect you to follow-up on it, but that's the process that I find working best.

For this PR, since we are breaking the API anyway, let's not enable rand by default.

@LukasKalbertodt
Copy link
Contributor Author

@kvark Sounds reasonable. I pushed a commit removing rand from default features.

In general, I could see myself helping out to work on and co-maintain cgmath, in case there aren't enough people available. However, I have to hand in my master thesis (that project is using cgmath btw) in one month, so I don' exactly have a lot of time to spare. But afterwards, I'm available again, if there is interest from your side.

@kvark
Copy link
Collaborator

kvark commented May 3, 2019

bors r+

bors bot added a commit that referenced this pull request May 3, 2019
483: Make `rand` dependency optional (but enabled by default) r=kvark a=LukasKalbertodt

Closes #481 

This PR leaves the feature enabled by default so that this can be released as a minor version soon. (I would suggest to disable it by default in future versions, but that's another discussion.)

The changes are pretty straight forward with one catch: I changed some `use` statements to nested imports (otherwise, there would be even more `#[cfg(feature = "rand")]` lines). Nested imports were stabilized in 1.25 (see [the edition guide on this feature](https://doc.rust-lang.org/edition-guide/rust-2018/module-system/nested-imports-with-use.html)). I'm not sure how cgmaths policy on minimum compiler version is. Maybe cgmath already requires a >= 1.25 compiler for other reasons. If my change is a problem, just tell me and I will change the imports back.

Co-authored-by: Lukas Kalbertodt <lukas.kalbertodt@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 3, 2019

Build succeeded

@bors bors bot merged commit 31cb9eb into rustgd:master May 3, 2019
@LukasKalbertodt LukasKalbertodt deleted the make-rand-optional branch May 3, 2019 15:04
@kvark kvark changed the title Make rand dependency optional (but enabled by default) Make rand dependency optional May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make rand implementations optional (with a Cargo feature)
2 participants