Python site packages

Michael Jansen kde at michael-jansen.biz
Sun Jan 20 15:11:54 UTC 2013


On Sunday, January 20, 2013 08:37:28 PM Ben Cooksley wrote:
> On Sun, Jan 20, 2013 at 12:55 PM, Kevin Kofler <kevin.kofler at chello.at> wrote:
> > On Saturday 19 January 2013 at 22:33:19, David Faure wrote:
> >> Because this breaks "make install" for developers.
> >> 
> >> (For the recommended case of installing as user rather than as root).
> >> The default should make it easy for everyone who wants to contribute to
> >> KDE.> 
> > But that makes things harder for packagers, for the benefit of the vocal,
> > but very small, minority of users who compile KDE directly from source.
> Are you implying that KDE Developers are a "small minority of users"?
> 
> Do remember that developers have to compile and install the same
> sources as well, and for many reasons most do not want their
> self-compiled version to affect the system in any way. This build
> system change lowers the barrier to entry for KDE Development in my
> view and should be retained.
> 
> It is far easier for packagers (who have experience and the benefits
> of being directly notified of this change) to add a single CMake
> argument to their build scripts than it is for all new developers to
> discover and then use this option. Running into a installation problem
> will just dissuade them and will ultimately harm the KDE Community in
> the long term.
> 
> >         Kevin Kofler


How about we make all of them happy?

First diff:diff --git a/cmake/modules/FindPythonLibrary.cmake b/cmake/modules/FindPythonLibrary.cmake
index 7cef79b..7e36347 100644
--- a/cmake/modules/FindPythonLibrary.cmake
+++ b/cmake/modules/FindPythonLibrary.cmake
@@ -58,8 +58,10 @@ if (PYTHONINTERP_FOUND)
     if(INSTALL_PYTHON_FILES_IN_PYTHON_PREFIX)
         set(PYTHON_SITE_PACKAGES_INSTALL_DIR ${PYTHON_SITE_PACKAGES_DIR})
     else()
-        set(PYTHON_SITE_PACKAGES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/python${PYTHON_SHORT_VERSION}/site-packages
-            CACHE PATH "The directory where Python modules will be installed to.")
+        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
+                       )
         message(STATUS "The Python files will be installed to ${PYTHON_SITE_PACKAGES_INSTALL_DIR}. Make sure to add them to the Python search path (e.g. by setting PYTHONPATH)")
     endif()


This should fix the problem with site/dist-packages.

Together with:

sysconfig.get_config_vars( 'base' ) or 'prefix'

it should even be able to only print the warning "The Python ...." if CMAKE_INSTALL_PREFIX ist different from the python PREFIX.

Sorry. Just had enough time to research the problem. Not enough time to do the change and a review request. Perhaps someone else can pick up here.

Mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/release-team/attachments/20130120/30530111/attachment.html>


More information about the release-team mailing list