I am running into issues with finding Python in combination with a “standalone” (static) python. This is a minimal CMakeLists.txt
I use for testing:
cmake_minimum_required(VERSION 3.16)
project(foo)
find_package(Python REQUIRED COMPONENTS Development)
In my case I am trying to discover the python unzipped from this archive. The directory structure of the extracted archive is fairly standard. Here is an (abbreviated) directory structure:
path/to/unzipped/archive
└── python
├── bin
│ ├── python3 -> python3.11
│ ├── python3.11
│ ├── ...
├── include
│ └── python3.11
│ ├── Python.h
│ └── ...
├── lib
│ ├── libpython3.11.so -> libpython3.11.so.1.0
│ ├── libpython3.11.so.1.0
│ ├── libpython3.so
│ ├── ...
└── ...
I have tried various way to give cmake a hint where to find Python:
- specifying `-D Python3_ROOT_DIR=path/to/unzipped/archive/python
- adding
path/to/unzipped/archive/python/bin
toPATH
- specifying
Python3_EXECUTABLE=path/to/unzipped/archive/python/bin/python3
,Python3_LIBRARY=path/to/unzipped/archive/python/lib/libpython3.so
Python3_INCLUDE_DIR=path/to/unzipped/archive/python/include
but without success. I always get this error:
CMake Error at /usr/share/cmake-3.22/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):
/usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.22/Modules/FindPython.cmake:561 (find_package_handle_standard_args)
CMakeLists.txt:4 (find_package)
I can’t really think of a reason why its failing to discover it
My environment:
- cmake version 3.22.1
- Linux jammy 6.2.0-32-generic #32~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 18 10:40:13 UTC 2 x86_64 x86_64 x86_64 GNU/Linux