-
Notifications
You must be signed in to change notification settings - Fork 760
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
Define missing import APIs #1475
Conversation
a8e13ef
to
9821882
Compare
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 for adding these. Can they please be located in src/ffi/cpython/import.rs
?
We try to match the cpython header structure as much as possible to make it easier to diff against upstream changes.
If you're willing to put the definitions as the same order as they currently are in the cpython header, that'd also be much appreciated.
src/ffi/import.rs
Outdated
} | ||
|
||
#[cfg(not(Py_LIMITED_API))] | ||
extern "C" { |
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.
This extern block contains pub static mut
so it's going to need #[cfg_attr(windows, link(name = "pythonXY"))]
Also can confirm that none of these APIs appear to exist for PyPy. |
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. As David says, please consider placing some APIs in cpython
mod. We're refactoring the FFI module in that way (#1289).
9821882
to
ac6335a
Compare
src/ffi/cpython/import.rs
Outdated
#[allow(unused)] | ||
pub fn PyImport_ExtendInittab(newtab: *mut _inittab) -> c_int; |
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.
For some reason I'm getting a compiler warning about PyImport_ExtendInittab()
being unused, so I suppressed this. Unsure why. Maybe the presence of the pub static mut
above triggers it?
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.
Yeah, that was it. I moved this to its own block 🤷♂️
ac6335a
to
40c0098
Compare
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! Just a final couple of tweaks needed before merging.
Strange, I can't reproduce the unused code warning if I remove those two attributes from the static mut
variables...
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 current comments cover everything in import.h from CPython master.
@indygreg thanks for pushing this PR along to this point; I'm going to take it over and push a commit shortly to finish it off as part of some tidy-ups I'm doing for the 0.14 release. |
Co-authored-by: Nicholas Sim <nsim+github@posteo.net>
09e5aac
to
754c27f
Compare
I need some of these APIs for the pyembed crate (used as part of
PyOxidizer). I figured I might as well define them all.
All these APIs are limited.
I don't have a PyPy install with a shared library to test. We may need to disable these when targeting PyPy.