-
Notifications
You must be signed in to change notification settings - Fork 802
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
Use addr_of_mut in pyo3-ffi #2172
Conversation
pyo3-ffi/build.rs
Outdated
Ok(()) | ||
} | ||
|
||
fn rustc_minor_version() -> Option<u32> { |
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.
PyO3 itself already uses the rustversion
, wouldn't it make sense to apply it here as well?
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.
The rustversion
crate? That is only a dev dependency.
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.
Indeed, wouldn't also just be build-dependency if used in the build script here?
I understand that it is meant to be used directly for conditional compilation, but that could also be applied to the println!
invocation in the build script to avoid manually parsing the version.
Or at least could we somehow deduplicate the parsing code between the build scripts of pyo3
and pyo3-ffi
?
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.
Last time I discussed it @davidhewitt (I think?) didn't want to add dependencies, so I didn't do it here. I would prefer not to reinvent the wheel but I also don't want to add more macro crates as dependencies.
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 feel kind of split between deduplicating the code - I don't like duplication either but it's not a whole lot and it doesn't do anything clever, so i don't think the cost of duplication is great here. And we'll just delete it all next time we bump msrv.
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.
Yes, I keep going back and forth whether we should add rustversion
and refactor our build scripts. On the one hand, it might be nice to use the dependency to keep our code a bit simpler. On the other, it keeps our dependency tree leaner to just do it ourselves. I slightly prefer the current implementation, though only slightly so if you folks wanted to change to rustversion
that's fine by me.
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.
To avoid the duplication could always shove it into pyo3-build-config
as a #[doc(hidden)]
API :P
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.
The current implementation is pretty simple. I'll just keep that.
To avoid the duplication could always shove it into pyo3-build-config as a #[doc(hidden)] API :P
Yeah, I'll do just that.
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.
Thanks, a nice tidy up!
Happy for you folks to decide on rustversion
and addr_of_mut
/ addr_of_mut_shim
and merge at your leisure.
All these comparisons and getters were going through &mut references to mutable statics...