Adopt PEP 793 module export hooks for C extensions (keep PyInit for compatibility)#19482
Adopt PEP 793 module export hooks for C extensions (keep PyInit for compatibility)#19482davin-core wants to merge 7 commits intoastropy:mainfrom
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
|
@neutrinoceros I am seeing repeated failures in py311-test-image-mpldev-cov on TestBasic.test_noncelestial_angular in |
|
I've been aware of this problem for a couple days but have not taken the time to open an issue yet (I will now). In any case it's definitely unrelated to this PR and not blocking for either review or merge. |
|
(for posterity this unrelated error is now discussed at #19483) |
|
Thank you for opening this. I need to read through the PEP to review this carefully. I'll plan to do it tomorrow. Meanwhile, I have an observation: I would expect that the existing declarations using |
|
@neutrinoceros Thank you for the feedback! I think your suggestion makes sense. I can improve my PR by wrapping the new PEP 793 slots-style module init in |
|
Yes, that is what I mean. I don't think defining a macro is necessary, especially since I can't think of a natural place for it to live (though I'm open to suggestions)
|
Signed-off-by: Davin <dev.davicheanin@gmail.com>
neutrinoceros
left a comment
There was a problem hiding this comment.
this is better, but now I'm seeing a handful of definitions that are only ever used in the <=3.14 path (including, but not necessarily limited to a couple static struct PyModuleDef). Could you move these to the appropriate region so they're simply not included unless they're needed ?
|
@neutrinoceros I will
Does that sound right to you? |
|
yes |
Signed-off-by: Davin <dev.davicheanin@gmail.com>
neutrinoceros
left a comment
There was a problem hiding this comment.
I'm seeing a couple #if !defined(...) directives. I would prefer we keep the style as uniform as possible to ease cleanup and followup refactors in the future; can we normalize the style to #if defined(...) / #else, ideally using a single if/else pair per module ?
Co-authored-by: Clément Robert <cr52@protonmail.com>
Signed-off-by: Davin <dev.davicheanin@gmail.com>
|
@neutrinoceros Thanks for the review and the style suggestion. I updated the module-init conditionals to use a uniform #if defined(...) / #else pattern, and removed the #if !defined(...) . I see that it is only in fast_sigma_clip.c |
|
Thank you ! |
|
From my understanding, Python 3.15 is currently in its alpha stage. I could create a virtual environment, pull this PR branch, and try to trigger the relevant functions. I can then report back on any issues I encounter. I could consider introducing a targeted test suite to help ensure compatibility with Python 3.15. |
|
yes, it's in alpha stage right now. The last alpha is expected in about 10 days.
that wouldn't work for us, as numpy doesn't have compatible binaries yet, and we don't want to spend compute time on building numpy. This is why I'm asking for a plan to test locally. |
|
then I am not sure too, perhaps we wait until we get more support before we test and mergred it then? |
|
hum, so you mean you have not checked the validity of your own patch before submitting this PR ? This is a bit unsettling. For reference, one way to check your patch compiles correctly, using uv, is1 I could confirm that it builds correctly. Then, I attempted to run tests with and hit an exception at collection time: AttributeError: module 'astropy.time._parse_times' has no attribute 'dt_pars'In order to make make sure the error was specific to your branch I also did the same thing on Footnotes
|
This PR adds PEP 793-style module export hooks (PyModExport_*) to Astropy C extensions that currently define modules via PyModuleDef_HEAD_INIT.
What changed
Added guarded slot-based module export definitions in:
fixes #19478
do let's me know if I am misssing something. I am quite new to the code base