Skip to content

Fix C extension build for unsupported Python versions#117

Merged
Marco-Sulla merged 1 commit into
Marco-Sulla:masterfrom
jvulgan:fix-extension-declaration
May 8, 2026
Merged

Fix C extension build for unsupported Python versions#117
Marco-Sulla merged 1 commit into
Marco-Sulla:masterfrom
jvulgan:fix-extension-declaration

Conversation

@jvulgan
Copy link
Copy Markdown
Contributor

@jvulgan jvulgan commented May 8, 2026

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.

@jvulgan
Copy link
Copy Markdown
Contributor Author

jvulgan commented May 8, 2026

@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.

@tonisbones
Copy link
Copy Markdown

🙏

@Marco-Sulla
Copy link
Copy Markdown
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
@jvulgan jvulgan force-pushed the fix-extension-declaration branch from 62a8e3c to a893bf0 Compare May 8, 2026 18:41
@jvulgan
Copy link
Copy Markdown
Contributor Author

jvulgan commented May 8, 2026

Thanks for the quick review :) I've changed it to the way it was before 11d3511

@Marco-Sulla Marco-Sulla merged commit 7fc66fb into Marco-Sulla:master May 8, 2026
53 checks passed
@Marco-Sulla
Copy link
Copy Markdown
Owner

Thanks for the quick review :)

Just pure luck. I check my mail only once a day X-D

Ty for the fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants