Bug 507459

Summary: Generated Python binding files installed in the wrong place for Debian systems
Product: [Frameworks and Libraries] frameworks-kguiaddons Reporter: bluescreenavenger
Component: generalAssignee: kdelibs bugs <kdelibs-bugs-null>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description bluescreenavenger 2025-07-24 20:47:25 UTC
This is ALL 8 (at time of writing) frameworks that install python bindings, not just kguiaddons, I am reporting against kguiaddons because it looks like kguiaddons was first

SUMMARY
The generated python binding files are installed under $INSTALLDIR/local/lib/python3.13/dist-packages/ or in my case /opt/local/lib/python3.13/dist-packages/

Debian/Ubuntu tends to not install Python files under /$INSTALLDIR/local/lib/ but under /$INSTALLDIR/lib/python3.13/site-packages/ and I can validate with "apt-file search /usr/local/lib"

Debian, seems to have its own way of handing Python that is unique to other distros AFAIK

You might want to use something like this, and I only got it through grepping, and finding this is how fontconfig installs their bindings, they use sysconfig.get_python_lib from distutils. I don't know the arguments they are passing the 0's to, I am not really 100% familiar with it. But yeah. and you might also want to append the project name at the end I think (like $INSTALLDIR/local/lib/python3.13/dist-packages/KGuiAddons/KGuiAddons.cpython-313-x86_64-linux-gnu.so), some packages do that, although not all do, so maybe that is not required
```
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index e97b173..23e924f 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -31,7 +31,7 @@ ecm_generate_python_bindings(
 
 target_link_libraries(${bindings_library} PRIVATE KF6Notifications)
 
-execute_process(COMMAND ${Python_EXECUTABLE} -Esc "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '${CMAKE_INSTALL_PREFIX}', 'base': '${CMAKE_INSTALL_PREFIX}'}))" OUTPUT_VARIABLE sysconfig_output)
+execute_process(COMMAND ${Python_EXECUTABLE} -Esc "from distutils import sysconfig; print(sysconfig.get_python_lib(0, 0, '${CMAKE_INSTALL_PREFIX}'))" OUTPUT_VARIABLE sysconfig_output OUTPUT_VARIABLE sysconfig_output)
 string(STRIP ${sysconfig_output} PYTHON_INSTALL_DIR)
 
 install(TARGETS ${bindings_library} LIBRARY DESTINATION "${PYTHON_INSTALL_DIR}")
```

Right now, Ubuntu seems to have the latest one where building the Python bindings is turned on by default, looks like they explicitly disabled it for now, but when they go to re-enable it it might be an issue


SOFTWARE/OS VERSIONS
Operating System: Debian
KDE Plasma Version: 6.4.80
KDE Frameworks Version: 6.17.0
Qt Version: 6.9.2
Kernel Version: 6.15.7 (64-bit)