Bindings: Support using sys paths for python install directory

Authored by bruns on Sep 30 2018, 8:48 PM.

Description

Bindings: Support using sys paths for python install directory

Summary:
The correct install directory is distro and arch specific, and should
match the configuration of the python installation the binding is
generated for. These directories can be queried using pythons
distutils.sysconfig.

When determining the install directory, it mimics the logic from
KDE_INSTALL_USE_QT_SYS_PATHS. When the python PREFIX is the same
as CMAKE_INSTALL_PREFIX, it defaults to using the path from
distutils.sysconfig, otherwise it keeps the current scheme, installing
below CMAKE_INSTALL_PREFIX.

The default behaviour can be changed by setting KDE_INSTALL_PYTHON{2,3}DIR
or by switching KDE_INSTALL_USE_PYTHON{2,3}_SYS_PATH ON or OFF.

Test Plan:
On a distro where sitearch is not below /usr/lib/pythonM.m/, but
/usr/lib64/pythonM.m/ (e.g. RH, SUSE 64bit), try to do:

cmake ..; make; install

Without the patch, the binding are installed into the wrong directory,
afterwards the correct path is used.

This should also yield the correct path on Debian and derivatives,
where dist-packages instead of site-packages is used (untested).

other test cases:
Keep current scheme: cmake -DCMAKE_INSTALL_PREFIX=/opt ..
Default to sys path: cmake -DCMAKE_INSTALL_PREFIX=/usr ..
Force sys path: cmake -DCMAKE_INSTALL_PREFIX=/opt -DKDE_INSTALL_USE_PYTHON3_SYS_PATHS=ON ..

Reviewers: Frameworks

Subscribers: bcooksley, kde-frameworks-devel, kde-buildsystem

Tags: Frameworks, Build System

Differential Revision: https://phabricator.kde.org/D15070