fix(toolkit): populate Python3_SOABI from sysconfig when empty#165
Merged
michaeltryby merged 1 commit intopyswmm:devfrom Apr 29, 2026
Merged
fix(toolkit): populate Python3_SOABI from sysconfig when empty#165michaeltryby merged 1 commit intopyswmm:devfrom
michaeltryby merged 1 commit intopyswmm:devfrom
Conversation
When NO_STABLE_ABI=1, the build sets SOABI=".${Python3_SOABI}". If
CMake's FindPython3 fails to populate Python3_SOABI, the suffix
collapses to "." and extension modules are linked as `_solver..so` /
`_output..so`, which Python cannot import.
Fall back to `sysconfig.get_config_var('SOABI')` via the interpreter
when the CMake variable is empty.
Also add a ctest guardrail (ExtensionSuffix_output, ExtensionSuffix_solver)
that asserts each built module has no double-dot and ends with a valid
`importlib.machinery.EXTENSION_SUFFIXES` entry, and wire a regression
step into unit_test.yml so the NO_STABLE_ABI path is exercised on
Linux, macOS, and Windows.
Refs pyswmm#155
Author
|
@michaeltryby @karosc Let me know if any changes are needed for this PR. |
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.
Summary
Fixes the double-dot extension filename (e.g.
_solver..so,_output..so) produced whenNO_STABLE_ABI=1is set and CMake'sFindPython3fails to populatePython3_SOABI. The malformed suffix makes the compiled modules unimportable, which is the likely root cause of #155.The build does
set(SOABI ".${Python3_SOABI}"), so an emptyPython3_SOABIcollapses the suffix to a single.and the linker emits_solver..so.What this PR does
swmm-toolkit/src/swmm/toolkit/CMakeLists.txt, whenPython3_SOABIis empty under theNO_STABLE_ABIbranch, query the interpreter forsysconfig.get_config_var('SOABI')and use that. This is the canonical source of the ABI tag.ExtensionSuffix_output,ExtensionSuffix_solver) that assert each built module exists, has no..in its basename, and ends with a validimportlib.machinery.EXTENSION_SUFFIXESentry.enable_testing()is added at the project root to support this.unit_test.ymlthat performs a direct CMake build withNO_STABLE_ABI=1and runscteston Linux, macOS, and Windows. The existing wheel test only covers the default stable-ABI path, so without this step the fallback has no CI coverage.Verification (local, macOS arm64, Python 3.14)
NO_STABLE_ABI=1_output.cpython-314-darwin.so,_solver.cpython-314-darwin.so_output.abi3.so,_solver.abi3.so_solver..soDouble-dot ABI bugTest plan
NO_STABLE_ABI=1Unit Testworkflow passes on Ubuntu, macOS, Windows (including the new regression step)Refs #155