Python_SOABI should match version of find_package(Python3 VERSION)

The following CMake statement:

find_package(Python3 3.11 EXACT COMPONENTS Development Interpreter REQUIRED)
message("The extension suffix is: ${Python_SOABI}")

Produces:

The extension suffix is: cpython-312-x86_64-linux-gnu

The docs say about Python_SOABI:

Python_SOABI

Added in version 3.17.

Extension suffix for modules.

Information computed from sysconfig.get_config_var('EXT_SUFFIX') or sysconfig.get_config_var('SOABI') or python3-config --extension-suffix.

The SOABI is indeed was I get when I type python3-config --extension-suffix in my terminal:

python3-config --extension-suffix
.cpython-312-x86_64-linux-gnu.so

I requested a different version however from find_package. Could the version obtained from find_package somehow be correlated with the SOABI version?

Very strange behavior for the following reason: When the Interpreter component is specified, the python-config tool is not used because various information are retrieved from the Python interpreter itself (as described in the doc: sysconfig package is used).

Moreover, the description of the SOABI computation is a simplification of the real algorithm: when the python-config tool is involved, the exact version is used (for example python3.11-config), and fallback to python3-config if not available.

And to finish, I am not able to reproduce your problem. I suspect an erroneous configuration of the various python versions…