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
The FindPythonLibsNew.cmake module launches a Python interpreter to determine some key properties for building of pybind11 and any dependent projects that may rely on cmake for configuration. In a cross-compilation environment, this causes at least three issues:
If target-architecture executables are not compatible with the host platform, the cmake module will either fail to execute the Python interpreter or will execute an interpreter on the host. Note that it is generally not possible to invoke the target Python interpreter in a cross-compilation environment because the target executable may not be compatible with the host platform.
When the host and target platforms have different pointer sizes and the cmake module attempts to run the Python interpreter from the host, FindPythonLibsNew.cmake may will fail with a FATAL_ERROR complaining that the bitness of Python and the chosen compiler do not agree if the module falls back to the host interpreter.
The variable PYTHON_MODULE_EXTENSION variable, set from distutils.sysconfig.get_config_var('SO') (note: it seems that the SO variable is deprecated and should be replaced with EXT_SUFFIX) and assigned to the SUFFIX target property in pybind11Tools.cmake, may be wrong when the extension of the host interpreter includes architecture information from the host and the host interpreter is invoked by the module.
If the host and target Python interpreters have compatible version numbers and configurations, all but the PYTHON_SIZEOF_VOID_P and PYTHON_MODULE_EXTENSION variables may be propertly determined from executing the host interpreter. Nevertheless, relying on executing the Python interpreter to determine key configuration values is always prone to error in cross-compilation environments.
What is to be done?
Removing the dependency on FindPythonLibsNew.cmake and instead relying on FindPython.cmake that ships with cmake at least moves the Python configuration discovery problem outside of the pybind11 project back to cmake, where the incentive to support cross-platform and cross-compilation environments is much greater.
At a minimum, removing the PYTHON_SIZEOF_VOID_P check avoids the immediate problem. Allowing manual override of other variables would allow cmake projects that depend on pybind11 to force proper behavior in a cross-compilation environment. (I assume this is mostly an issue for packagers.)
The text was updated successfully, but these errors were encountered:
Issue description
The
FindPythonLibsNew.cmake
module launches a Python interpreter to determine some key properties for building ofpybind11
and any dependent projects that may rely on cmake for configuration. In a cross-compilation environment, this causes at least three issues:If target-architecture executables are not compatible with the host platform, the cmake module will either fail to execute the Python interpreter or will execute an interpreter on the host. Note that it is generally not possible to invoke the target Python interpreter in a cross-compilation environment because the target executable may not be compatible with the host platform.
When the host and target platforms have different pointer sizes and the cmake module attempts to run the Python interpreter from the host,
FindPythonLibsNew.cmake
may will fail with aFATAL_ERROR
complaining that the bitness of Python and the chosen compiler do not agree if the module falls back to the host interpreter.The variable
PYTHON_MODULE_EXTENSION
variable, set fromdistutils.sysconfig.get_config_var('SO')
(note: it seems that theSO
variable is deprecated and should be replaced withEXT_SUFFIX
) and assigned to theSUFFIX
target property inpybind11Tools.cmake
, may be wrong when the extension of the host interpreter includes architecture information from the host and the host interpreter is invoked by the module.If the host and target Python interpreters have compatible version numbers and configurations, all but the
PYTHON_SIZEOF_VOID_P
andPYTHON_MODULE_EXTENSION
variables may be propertly determined from executing the host interpreter. Nevertheless, relying on executing the Python interpreter to determine key configuration values is always prone to error in cross-compilation environments.What is to be done?
Removing the dependency on
FindPythonLibsNew.cmake
and instead relying onFindPython.cmake
that ships with cmake at least moves the Python configuration discovery problem outside of the pybind11 project back to cmake, where the incentive to support cross-platform and cross-compilation environments is much greater.At a minimum, removing the
PYTHON_SIZEOF_VOID_P
check avoids the immediate problem. Allowing manual override of other variables would allow cmake projects that depend on pybind11 to force proper behavior in a cross-compilation environment. (I assume this is mostly an issue for packagers.)The text was updated successfully, but these errors were encountered: