Fix C extension build for unsupported Python versions#117
Merged
Conversation
Contributor
Author
|
@Marco-Sulla please have a look. If you try to build the wheel on python version that don't support the C extensions without using the env var for specifying if you want the pure-python wheel or not, it will build a wheel which is itself pure-python but declares it uses the C extensions which seems like a bug. |
|
🙏 |
Owner
|
Confirmed. It's a regression introduced in commit 11d3511. I must say I prefer the code as it was before the commit, it's more DRY. Can you do it? :) |
When the C source directory does not exist for the running Python version (e.g. 3.11+), the build silently skips compilation due to optional=True but still declares ext_modules, producing a wheel tagged as platform-specific (cp312-cp312-linux_x86_64) with no native code inside. Check whether c_src/<version>/ exists before declaring the C extension. If it does not, fall back to pure-Python mode so the wheel is correctly tagged as py3-none-any. Regression introduced in 11d3511
62a8e3c to
a893bf0
Compare
Contributor
Author
|
Thanks for the quick review :) I've changed it to the way it was before 11d3511 |
Owner
Just pure luck. I check my mail only once a day X-D Ty for the fix :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the C source directory does not exist for the running Python version (e.g. 3.11+), the build silently skips compilation due to optional=True but still declares ext_modules, producing a wheel tagged as platform-specific (cp312-cp312-linux_x86_64) with no native code inside.
Check whether c_src// exists before declaring the C extension. If it does not, fall back to pure-Python mode so the wheel is correctly tagged as py3-none-any.