You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[galactic] [BUG] When cross compiling to aarch64 from x86_64 host PYTHON_MODULE_EXTENSION is not set #9
I set PYTHON_SOABI cmake variable in the toolchain, but the name of the libraries were not set correctly.
Expected behavior:
<lib_name>.cpython-36m-aarch64-linux-gnu.so
Actual behavior:
<lib_name>.cpython-36m-x86_64-linux-gnu.so
I fixed the problem by setting PYTHON_MODULE_EXTENSION variable, which is used by pybind11, to PYTHON_SOABI here
execute_process(
COMMAND"${${_Python}_EXECUTABLE}""-c""import sys, importlib; s = importlib.import_module('distutils.sysconfig' if sys.version_info < (3, 10) else 'sysconfig'); print(s.get_config_var('EXT_SUFFIX') or s.get_config_var('SO'))"OUTPUT_VARIABLE_PYTHON_MODULE_EXTENSIONERROR_VARIABLE_PYTHON_MODULE_EXTENSION_ERROUTPUT_STRIP_TRAILING_WHITESPACE)
This could (not in a portable way) be done by using qemu and running the sysroot's version of Python instead, under the rationale you need qemu to create the sysroot. (But some might just have the sysroot built for them)
Our quick solution is to fix those variables according to the python command executed on target (or though chroot & qemu in the sysroot)
python3 -c "import sys, importlib; s = importlib.import_module('distutils.sysconfig' if sys.version_info < (3, 10) else 'sysconfig'); print(s.get_config_var('EXT_SUFFIX') or s.get_config_var('SO'))"
# See: https://github.com/ros2/pybind11_vendor to have pybind11 version, then# See: https://github.com/pybind/pybind11/blob/8a4bca8216f94f64d9582997db5e7eaf2e4660b3/tools/pybind11NewTools.cmake#L98-L111# Note the point!set(PYTHON_MODULE_EXTENSION ".cpython-39-aarch64-linux-gnu.so")
# python_cmake_module workaround, PYTHON_MODULE_EXTENSION is set to PYTHON_SOABI# See: https://github.com/ros2/python_cmake_module/blob/d31a0b13225786e076e537a6f1ba67ba5cb2e620/cmake/Modules/FindPythonExtra.cmake#L159-L197# Note the lack of point & .soset(PYTHON_SOABI cpython-39-aarch64-linux-gnu)
Activity
AlexisTM commentedon Oct 18, 2022
It seems to be quite a long standing issue ;)
I have been getting the same issue. The core problem being the suffix is being computed in the host instead of the target python interpreter.
The logic is close to Pybind11's version:
https://github.com/pybind/pybind11/blob/914c06fb252b6cc3727d0eedab6736e88a3fcb01/tools/pybind11NewTools.cmake#L110-L116
This could (not in a portable way) be done by using qemu and running the sysroot's version of Python instead, under the rationale you need qemu to create the sysroot. (But some might just have the sysroot built for them)
AlexisTM commentedon Oct 18, 2022
Our quick solution is to fix those variables according to the python command executed on target (or though chroot & qemu in the sysroot)
Linked to ros2/pybind11_vendor#16