-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
python: Use correct extension filename suffix on Python < 3.8.7 #10961
Conversation
5f6d17c
to
0eef3af
Compare
I'd say this qualifies for inclusion to rc2. |
Does meson really support building extensions for Python 2.x? I didn't know that and the test failures reflect that. I just pushed an updated patch that should work building for Python 2.x as well. |
0eef3af
to
aa74731
Compare
In theory yes, but I don't know if that's tested, so I would not be surprised if it's broken. |
It is tested in the CI jobs, the test failures are what me realize it is a thing. |
I mean, the fact that the CI failed presumably means that it is in fact tested? Not sure how else that would work lol. |
For the record, this is false. The sysconfig module does not provide the wrong suffix. It provides a valid suffix, but a less awesome one. ... According to mesonbuild/meson-python#189 this PR doesn't even fix the issue, though, and the real fix will be to stop expecting the wheel filename to exactly match the extension filename suffix? Do we even need to make this code more complex? |
Codecov Report
@@ Coverage Diff @@
## master #10961 +/- ##
===========================================
- Coverage 68.58% 50.46% -18.13%
===========================================
Files 412 207 -205
Lines 87861 44888 -42973
Branches 20728 9919 -10809
===========================================
- Hits 60261 22652 -37609
+ Misses 23093 20196 -2897
+ Partials 4507 2040 -2467
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
AFAIU, the extension module generated by Meson cannot be loaded by Python < 3.8.7 on Windows as it has the wrong file name. This is independent from packaging the extension into a Python wheel. |
What makes you believe this? Python is supposed to load backwards-compatible (2.x-style) extension filename suffixes that don't have a version tag, for example on Linux it will try to load (This can actually result in bugs if you manually mess with PYTHONPATH and end up accidentally adding python2 artifacts to a python3 interpreter -- it will try to load python2 modules, then fail with an ImportError due to missing C symbols for the CPython ABI.) It even checks more candidate filenames too, because there's the |
8096a82
to
06303a7
Compare
I stand corrected. I fixed the commit message accordingly. Is having the more awesome suffix something desirable? |
Well, the awesome suffix is, after all, more awesome. The only reasons to think about not doing it are:
|
This is the reason why I decided to use |
The test failures are various timeouts, most likely unrelated to this patch. |
Right. I don't even know that it's possible to just avoid using distutils at all (it's a nice thought to imagine we could). |
For the same reason, all the information now available via |
I meant avoid using it at all on any version. :p Might require debian to get serious about consistently patching their patches. |
I must admit that I don't completely understand the issue with Debian. It is a long time since I looked into this, but IIRC, the Debian Python is happy to load modules both from the |
Azure macos failure seems to be the test runner timing out in an unorderly way. I reconstruct the traceback to be:
|
I'm pretty sure they only do the former in /usr/local and only do the latter in /usr. |
06303a7
to
95a7975
Compare
Force pushed to retry the failing tests. |
I tried restarting it a couple times already though... rerunning the entire suite of 33 runners instead of pinging again to see if someone can restart it seems... slow. |
Yeah, sorry. I thought that pushing to the branch would have run all the tests without manual intervention from someone. It turns out that it still requires approval so no time spared for anyone. |
Windows test failure is significant. |
Thanks @eli-schwartz The log ends with what looks like a timeout uploading to Coverity and I focused on that instead on the real failure. I guess the |
Yes. Also #10979 for avoiding confusion in the future, this is not the first time. :D |
95a7975
to
f398b94
Compare
Thanks @eli-schwartz The |
Is it sufficient to have py_implib add the python suffix and instead of returning, continue on to the generic implib handling? |
I think it could be possible. I coded it this way because I am not sure that the filename prefix mangling done in the MSVC case applied to python extension modules and to keep the handling of the python specific file types in the same section of the code. If there is preference for having it coded as you suggest, I can change it in that direction. |
f398b94
to
82bb026
Compare
I've now implemented @eli-schwartz's suggestion. |
82bb026
to
9a06d44
Compare
Nope, went back to the former implementation, it is much simpler. |
Anything missing for merging this? The remaining test failure is unrelated and should be fixed by recent commits. Maybe @eli-schwartz can restart it to verify |
ping? |
Fixing the CI requires running it with recent commits, which in turn means rebasing -- when you restart CI, it just checks out the old merge result of "whatever the master branch was at when the PR was submitted", it doesn't try re-merging. |
On Windows, in Python version prior to 3.8.7, the `sysconfig` modules provides an extension filename suffix that disagrees the one returned by `distutils.sysconfig`. Get the more awesome suffix from the latter when building for a Python version known to present this issue. Simplify the extension module filename suffix lookup to use the same method used by `setuptools`. Adjust project tests accordingly. Fixes mesonbuild#10960.
9a06d44
to
d31cefc
Compare
Right, I forgot this, sorry. Rebased. |
All green! |
ping? |
In Python version prior to 3.8.7 the
sysconfig
provides the wrong suffix. The right one can be obtained fromdistutils.sysconfig
.distutils
is deprecated and will be removed in Python 3.12 thus get the information fromdistutils
only when building for a Python version know to present this issue.Simplify the extension module filename suffix lookup to use the same method used by
setuptools
.Fixes #10960.