]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Further simplify python3 build
authorMichael Schroeder <mls@suse.de>
Thu, 10 Nov 2016 10:15:20 +0000 (11:15 +0100)
committerMichael Schroeder <mls@suse.de>
Thu, 10 Nov 2016 10:15:20 +0000 (11:15 +0100)
bindings/python/CMakeLists.txt
bindings/python3/CMakeLists.txt
package/libsolv.spec.in

index 2612a8bdef0c81b539d098704150b4b6fdd2767a..7fb4af049e5c640864e80cc2beadca5c7e014abd 100644 (file)
@@ -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)
index 76e730a48975aafe4c7aa2d84fe6df62c5510b6d..7a2dca3cd308b985047bf7a60ba28775b01a53a4 100644 (file)
@@ -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}")
index 4327dc0111ae03362280d84683a0a649e44517cc..000928796c84066d01b6e2f00c32a509cbf00cc5 100644 (file)
@@ -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 \