From: Michael Schroeder Date: Thu, 10 Nov 2016 10:15:20 +0000 (+0100) Subject: Further simplify python3 build X-Git-Tag: 0.6.24~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad99683539a3d9e2300538fc640519cbd472fdb6;p=thirdparty%2Flibsolv.git Further simplify python3 build --- diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 2612a8bd..7fb4af04 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -1,7 +1,13 @@ -#SET (PythonLibs_FIND_VERSION 3) - -FIND_PACKAGE (PythonLibs) +IF (ENABLE_PYTHON3 AND NOT DEFINED PythonLibs_FIND_VERSION) + # if we build both for python2 and python3, make this the python2 build. + # see comment in the python3 CMakeLists.txt file + SET (PythonLibs_FIND_VERSION 2) + SET (PythonLibs_FIND_VERSION_MAJOR 2) +ENDIF IF (ENABLE_PYTHON3 AND NOT DEFINED PythonLibs_FIND_VERSION) + +FIND_PACKAGE (PythonLibs REQUIRED) FIND_PACKAGE (PythonInterp ${PYTHONLIBS_VERSION_STRING} REQUIRED) + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from sys import stdout; from distutils import sysconfig; stdout.write(sysconfig.get_python_lib(True))" OUTPUT_VARIABLE PYTHON_INSTALL_DIR) IF (NOT DEFINED PYTHON_VERSION_MAJOR) diff --git a/bindings/python3/CMakeLists.txt b/bindings/python3/CMakeLists.txt index 76e730a4..7a2dca3c 100644 --- a/bindings/python3/CMakeLists.txt +++ b/bindings/python3/CMakeLists.txt @@ -1,9 +1,17 @@ -# Needs the following cache variables: # -# PYTHON3_EXECUTABLE -# PYTHON3_INCLUDE_DIR +# used for building both python2 and python3 bindings +# do not use if you want to build just one flavor, use the +# standard python bindings file in that case. # +# we cannot use FIND_PACKAGE PythonLibs here, as this would +# clash with the python variables. +# +IF (NOT DEFINED ${PYTHON3_EXECUTABLE}) +SET (PYTHON3_EXECUTABLE "/usr/bin/python3") +ENDIF (NOT DEFINED ${PYTHON3_EXECUTABLE}) + EXECUTE_PROCESS(COMMAND ${PYTHON3_EXECUTABLE} -c "from sys import stdout; from distutils import sysconfig; stdout.write(sysconfig.get_python_lib(True))" OUTPUT_VARIABLE PYTHON3_INSTALL_DIR) +EXECUTE_PROCESS(COMMAND ${PYTHON3_EXECUTABLE} -c "from sys import stdout; from distutils import sysconfig; stdout.write(sysconfig.get_python_inc())" OUTPUT_VARIABLE PYTHON3_INCLUDE_DIR) MESSAGE (STATUS "Python3 executable: ${PYTHON3_EXECUTABLE}") MESSAGE (STATUS "Python3 installation dir: ${PYTHON3_INSTALL_DIR}") diff --git a/package/libsolv.spec.in b/package/libsolv.spec.in index 4327dc01..00092879 100644 --- a/package/libsolv.spec.in +++ b/package/libsolv.spec.in @@ -181,11 +181,6 @@ CMAKE_FLAGS="-DFEDORA=1" CMAKE_FLAGS="-DSUSE=1 -DENABLE_APPDATA=1 -DENABLE_COMPS=1" %endif -%if %{with python3_binding} -# build both for python2 and python3 -CMAKE_FLAGS="$CMAKE_FLAGS -DPythonLibs_FIND_VERSION=2 -DPythonLibs_FIND_VERSION_MAJOR=2 -DENABLE_PYTHON3=1 -DPYTHON3_EXECUTABLE=/usr/bin/python3 -DPYTHON3_INCLUDE_DIR=$(/usr/bin/python3-config --includes | sed -e 's/ .*//' -e 's/-I//')" -%endif - cmake $CMAKE_FLAGS \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DLIB=%{_lib} \ @@ -195,6 +190,7 @@ cmake $CMAKE_FLAGS \ %{?with_disable_shared:-DDISABLE_SHARED=1} \ %{?with_perl_binding:-DENABLE_PERL=1} \ %{?with_python_binding:-DENABLE_PYTHON=1} \ + %{?with_python3_binding:-DENABLE_PYTHON3=1} \ %{?with_ruby_binding:-DENABLE_RUBY=1} \ %{?with_zypp:-DENABLE_SUSEREPO=1 -DENABLE_HELIXREPO=1} \ -DUSE_VENDORDIRS=1 \