[PyPy] find_package(Python) doesn't work without Interpreter as Component, if another component is already specified
Consider the following project:
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
include_guard(GLOBAL)
project(t)
find_package(Python REQUIRED COMPONENTS Development)
For CPython, this works:
$ cmake -S t -Bbuild.py39 -DPython_FIND_IMPLEMENTATIONS=CPython
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python: /spare/scratch/1621372569/dev.py39/include/python3.9 (found version "3.9.4") found components: Development Development.Module Development.Embed
-- Configuring done
-- Generating done
-- Build files have been written to: /spare/scratch/1621372569/build.py39
However, for PyPy, it fails:
$ cmake -S t -Bbuild.pypy -DPython_FIND_IMPLEMENTATIONS=PyPy
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /spare/scratch/1621372569/dev.pypy/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Python (missing: Python_INCLUDE_DIRS Python_LIBRARIES
Development Development.Module Development.Embed)
Call Stack (most recent call first):
/spare/scratch/1621372569/dev.pypy/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/spare/scratch/1621372569/dev.pypy/share/cmake-3.20/Modules/FindPython.cmake:556 (find_package_handle_standard_args)
CMakeLists.txt:6 (find_package)
-- Configuring incomplete, errors occurred!
See also "/spare/scratch/1621372569/build.pypy/CMakeFiles/CMakeOutput.log".
If I add Interpreter
as a required component as well, then it succeeds:
$ diff -u t/CMakeLists.txt t/CMakeLists.txt.old
--- t/CMakeLists.txt 2021-05-18 17:39:05.314447327 -0400
+++ t/CMakeLists.txt.old 2021-05-18 17:38:56.590991138 -0400
@@ -3,4 +3,4 @@
project(t)
-find_package(Python REQUIRED COMPONENTS Interpreter Development)
+find_package(Python REQUIRED COMPONENTS Development)
$ cmake -S t -Bbuild.pypy -DPython_FIND_IMPLEMENTATIONS=PyPy
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python: /spare/scratch/1621372569/dev.pypy/bin/pypy3 (found version "3.7.10") found components: Interpreter Development Development.Module Development.Embed
-- Configuring done
-- Generating done
-- Build files have been written to: /spare/scratch/1621372569/build.pypy