Skip to content

Commit 1429b75

Browse files
authored
Fix Python extension library name (#3679)
When generating the name of the NEURON Python libraries (like `hoc.cp313.so`), we make use of `CMAKE_LIBRARY_ARCHITECTURE`. On Fedora with the clang compiler, `CMAKE_LIBRARY_ARCHITECTURE` is set to `x86_64-redhat-linux-gnu`, but Python does not recognize this extension when importing: ``` $ python -c 'import importlib.machinery;print(importlib.machinery.EXTENSION_SUFFIXES)' ['.cpython-313-x86_64-linux-gnu.so', '.abi3.so', '.so'] ``` The solution is to not rely on `CMAKE_LIBRARY_ARCHITECTURE` and just always set the extension to `${ARCH}-linux-gnu`, which should be importable in Python on all "reasonable" Linux platforms.
1 parent 191e426 commit 1429b75

1 file changed

Lines changed: 1 addition & 16 deletions

File tree

cmake/PythonCompileHelper.cmake

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,7 @@ function(add_nrn_python_library name)
125125
set(undefined_link_flag "-Wl,-undefined,dynamic_lookup")
126126
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
127127
set(rel_rpath_name "$ORIGIN")
128-
# sometimes CMAKE_LIBRARY_ARCHITECTURE is not set, so here we build it manually
129-
if(NOT CMAKE_LIBRARY_ARCHITECTURE)
130-
set(arch "${CMAKE_SYSTEM_PROCESSOR}")
131-
string(TOLOWER "${CMAKE_SYSTEM_NAME}" os)
132-
133-
if(arch STREQUAL "x86_64" OR arch STREQUAL "aarch64")
134-
set(lib_arch "${arch}-linux-gnu")
135-
else()
136-
set(lib_arch "${arch}-${os}")
137-
endif()
138-
139-
set(CMAKE_LIBRARY_ARCHITECTURE
140-
"${lib_arch}"
141-
CACHE INTERNAL "Guessed library architecture")
142-
endif()
143-
set(os_string "${CMAKE_LIBRARY_ARCHITECTURE}")
128+
set(os_string "${CMAKE_SYSTEM_PROCESSOR}-linux-gnu")
144129
set(lib_suffix "${CMAKE_SHARED_MODULE_SUFFIX}")
145130
set(python_interp "cpython-")
146131
set(undefined_link_flag "-Wl,--unresolved-symbols=ignore-all")

0 commit comments

Comments
 (0)