Build with Cmake: Doesn't build with python3.12 or higher: ModuleNotFoundError: No module named 'imp'
Problem description
In my projects CMakeLists.txt:
include(FetchContent)
FetchContent_Declare(
mavsdk
GIT_REPOSITORY https://github.com/mavlink/MAVSDK.git
GIT_TAG v2.2.0
GIT_SUBMODULES_RECURSE TRUE
)
FetchContent_MakeAvailable(mavsdk)
If cmake picks Python 3.12 (or higher) the build fails:
[cmake] ModuleNotFoundError: No module named 'imp'
imp has been removed in Python 3.12
Expected behavior
Works with Python >= 3.12
Side note:
I tried with
unset(Python3_EXECUTABLE)
find_package (Python 3.10 EXACT REQUIRED COMPONENTS Interpreter Development)
in cmake. However, this seems not to apply to dependencies as fetched by FetchContent_*
Idea
- Maybe adding
unset(Python3_EXECUTABLE)
find_package (Python 3.10 EXACT REQUIRED COMPONENTS Interpreter Development)
to the MavSDK CMakeLists.txt fixes the issue?
- Get rid of imp
We should probably do 2. Do you know where it's required?
This was happening in future egg but was corrected in 0.18.4 release: https://github.com/PythonCharmers/python-future/pull/632 (well 1.0.0 release because there is no 0.18.4 version on PyPI).
Ok, so potentially with latest future it should be ok again?
On my side at least it solved the problem.
Nice, ok!