1
0
Эх сурвалжийг харах

FindPython2: avoid doubling the extension in CPython2 SOABI

Commit 951640f1f9 (FindPython: manage SOABI for all Python versions,
2020-08-11) extended support for Python2's SOABI variable in order to
support the PyPy interpreter as well. This caused a regression in the
way that the SOABI variable was built up for the CPython interpreter.
This caused the variable to be set to `.so` which ended up causing a
doubling of the resulting `SOABI` variable in the end.

Co-Author: Marc Chevrier <[email protected]>
Fixes: #21548
Ben Boeckel 4 жил өмнө
parent
commit
afb0ffcac7

+ 10 - 2
Modules/FindPython/Support.cmake

@@ -452,7 +452,11 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME)
         list (REMOVE_DUPLICATES _values)
         list (REMOVE_DUPLICATES _values)
       elseif (NAME STREQUAL "SOABI")
       elseif (NAME STREQUAL "SOABI")
         # clean-up: remove prefix character and suffix
         # clean-up: remove prefix character and suffix
-        string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}")
+        if (_values MATCHES "^(\\.${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.so|\\.pyd)$")
+          set(_values "")
+        else()
+          string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}")
+        endif()
       endif()
       endif()
     endif()
     endif()
   endif()
   endif()
@@ -504,7 +508,11 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME)
         endforeach()
         endforeach()
         if (_values)
         if (_values)
           # clean-up: remove prefix character and suffix
           # clean-up: remove prefix character and suffix
-          string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}")
+          if (_values MATCHES "^(\\.${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.so|\\.pyd)$")
+            set(_values "")
+          else()
+            string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}")
+          endif()
         endif()
         endif()
       endif()
       endif()
     else()
     else()