Installing python __init__.py file from multiple KF5 frameworks

Luca Beltrame lbeltrame at kde.org
Thu May 19 08:56:05 BST 2016


In data giovedì 19 maggio 2016 09:40:54 CEST, Stephen Kelly ha scritto:

>  -DCMAKE_INSTALL_PREFIX=prefix

In the original PyKDE4, there was an option called 

-DINSTALL_PYTHON_FILES_IN_PYTHON_PREFIX=TRUE

which would figure things out by itself. It's part of FindPythonLibrary in 
KDELibs4Support.

Basically it does (taken directly from there)

# Auto detect Python site-packages directory
    execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig 
import get_python_lib; print(get_python_lib(True))"
                    OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_DIR
                    OUTPUT_STRIP_TRAILING_WHITESPACE
                   )

    message(STATUS "Python system site-packages directory: $
{PYTHON_SITE_PACKAGES_DIR}")
    if(INSTALL_PYTHON_FILES_IN_PYTHON_PREFIX)
        set(PYTHON_SITE_PACKAGES_INSTALL_DIR ${PYTHON_SITE_PACKAGES_DIR})
    else()
        execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from 
distutils.sysconfig import get_python_lib; print(get_python_lib(True, prefix='$
{CMAKE_INSTALL_PREFIX}'))"
                        OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_INSTALL_DIR
                        OUTPUT_STRIP_TRAILING_WHITESPACE
                       )
    endif()

This should IMO work and set the Python package dir as configured by the 
package distributor, with a lot less headache for the developer. 

> Can you tell me what I should have instead after install (on a debian
> system, so I know where dist-packages fits)?

In Debian, what you have is correct (checked on an Ubuntu 14.04 system). In 
other systems (Fedora, openSUSE is what I know) you may get /usr/lib{64}/
python2.7/site-packages. 

I would, however, use the logic from the above snippet as this removes the 
burden off you and does what the distributor configured the package to do.

-- 
Luca Beltrame - KDE Forums team
KDE Science supporter
GPG key ID: A29D259B
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/distributions/attachments/20160519/00895bf7/attachment.sig>


More information about the Distributions mailing list