Bug 15484 - pam_wrapper-1.1.5 fails to build when setting python paths manually
Summary: pam_wrapper-1.1.5 fails to build when setting python paths manually
Status: NEW
Alias: None
Product: cwrap
Classification: Unclassified
Component: library (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: Andreas Schneider
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-28 13:56 UTC by Timo Gurr
Modified: 2023-09-28 13:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timo Gurr 2023-09-28 13:56:22 UTC
To be able to build pam_wrapper for the selected python version e.g. Python 3.10 despite Python 3.11 also installed on the system we're passing the required Python path variables like:

-DPYTHON3_INCLUDE_DIR=/usr/x86_64-pc-linux-gnu/include/python3.11
-DPYTHON3_LIBRARY=/usr/x86_64-pc-linux-gnu/lib/libpython3.11.so
-DPYTHON3_SITELIB=lib/python3.11/site-packages

which results in a CMake failure since 1.1.5:

CMake Error at src/python/python3/CMakeLists.txt:35 (python_add_module):
  Unknown CMake command "python_add_module".

since the python_add_modules relies on find_package(PythonLibs 3) which never gets called when setting the python paths manually, this was probably working for 1.1.4 since it also included python2 checks.

A dirty hack to allow the above to succeed:

diff -Naur pam_wrapper-1.1.5/src/python/python3/CMakeLists.txt pam_wrapper-1.1.5.new/src/python/python3/CMakeLists.txt
--- pam_wrapper-1.1.5/src/python/python3/CMakeLists.txt	2023-08-08 11:14:01.000000000 +0200
+++ pam_wrapper-1.1.5.new/src/python/python3/CMakeLists.txt	2023-09-28 15:26:52.090147304 +0200
@@ -32,6 +32,7 @@
     include_directories(${pam_wrapper-headers_DIR})
     include_directories(${PYTHON3_INCLUDE_DIR})
 
+    find_package(PythonLibs 3)
     python_add_module(python3-pamtest ${pypamtest_SOURCE_DIR}/pypamtest.c)
     target_link_libraries(python3-pamtest pamtest::pamtest ${PYTHON3_LIBRARY})
     target_compile_options(python3-pamtest

FindPythonLibs is also deprecated since 3.12 and FindPython3 should be used instead so the proper fix would probably be to rework the checks completely and use FindPython3 instead, I'm no CMake expert though so I'm unable to do this myself to be able to contribute a proper fix.