-
Notifications
You must be signed in to change notification settings - Fork 787
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
inventory
& multiple-pymethods
#2210
Comments
Does |
I think that would be the best long-term solution. Especially since the underlying issue not specific to PyO3. |
It does, however not fully understanding the exact issue that's causing the problem (and the fact that I've not seen any reports on PyO3 of |
Not as well-organized as the original, but this is viable too: // Methods unique to this class
#[pymethods]
impl Foo {
// Methods common to many types
basic_magic_methods!();
getstate_setstate!();
// ...
} |
See rust-lang/rust#47384:
So, probably that's why you have no errors (yet?) because your |
I don't think this works - the |
This makes me curious: what's the priority of procedural macros and macro_rules? |
AFAIK it's always outermost macro gets expanded first, then inner ones. |
Similar to @davidhewitt's case, we use macros to generate python methods. The macros mimic Rust traits, that are defined in a |
Interested to see how you solve this as I'm both a user of pyo3 and inventory ... |
I haven't looked at how |
It's live again: |
For Rust 1.62+, though. But it's good news nonetheless! |
Yep. Since Debian 12 may freeze in 1/2023, we have a good chance of a new enough toolchain making it in there. |
Given that there's a possible soundness concern, I'd argue that in PyO3 0.17 we should actually update |
Fair enough. |
The
inventory
crate has been archived. This brings into question the future of themultiple-pymethods
feature, which currently depends oninventory
.As far as I know, the crate was archived because it relies on platform-dependent linker behaviour, and also has unstable behaviour on newer Rust versions (dtolnay/inventory#32).
Deprecating this feature is the simplest path, however it is also a decent ergonomic improvement. In my day job I maintain a PyO3 codebase which exports a large number of
#[pyclass]
structs. To avoid repetition we have macros to write standard magic methods, e.g.These helper macros basically extend to additional
#[pymethods]
blocks. Successfully migrating this codebase away frommultiple-pymethods
would require coming up with a suitable alternative pattern.As an alternative to deprecating the feature, I've been wondering whether to experiment with bringing a minimalist in-crate implementation of
linkme
- the#[distributed_slice]
concept should be enough to build#[pymethods]
here.In the long-term, it would be interesting to see if we can garner support for such a primitive in the language itself. See https://internals.rust-lang.org/t/from-life-before-main-to-common-life-in-main/16006
If a
#[distributed_slice]
implementation was landed in nightly Rust, we could then switch themultiple-pymethods
feature to be nightly-only, with the hope that it would one day be available on stable.The text was updated successfully, but these errors were encountered: