[gegl-qt] Python: Build bindings conditionally from qmake



commit 3f10d4111ba41755a9c099006b887768d9a9fe4c
Author: Jon Nordby <jononor gmail com>
Date:   Thu Sep 1 01:20:45 2011 +0200

    Python: Build bindings conditionally from qmake
    
    Also adds install target for bindings.

 config.pri               |    6 ++++
 examples/examples.pro    |    2 +
 examples/pyside-basic.py |    4 +-
 gegl-qt.pro              |   16 +++++++---
 pygegl-qt/.gitignore     |    3 +-
 pygegl-qt/Makefile       |   57 ----------------------------------
 pygegl-qt/pygegl-qt.pro  |   76 ++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 99 insertions(+), 65 deletions(-)
---
diff --git a/config.pri b/config.pri
index 46cb557..2aa97ba 100644
--- a/config.pri
+++ b/config.pri
@@ -41,6 +41,12 @@ HAVE_QT_DECLARATIVE = yes
     HAVE_QT_DECLARATIVE = no
 }
 
+HAVE_PYSIDE = yes
+!system(pkg-config pyside){
+    !build_pass:system(echo "PySide not found - no Python support")
+    HAVE_PYSIDE = no
+}
+
 GEGLQT_INSTALL_BIN = $$GEGLQT_INSTALL_PREFIX/bin
 GEGLQT_INSTALL_HEADERS = $$GEGLQT_INSTALL_PREFIX/include
 GEGLQT_INSTALL_LIBS = $$GEGLQT_INSTALL_PREFIX/lib
diff --git a/examples/examples.pro b/examples/examples.pro
index 49e451d..b5126f0 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -16,3 +16,5 @@ contains(HAVE_QT_DECLARATIVE, yes) {
         qml-paint \
 
 }
+
+OTHER_FILES += pyside-basic.py
diff --git a/examples/pyside-basic.py b/examples/pyside-basic.py
index 1b02259..df60562 100644
--- a/examples/pyside-basic.py
+++ b/examples/pyside-basic.py
@@ -8,7 +8,7 @@ from gi.repository import Gegl
 from PySide.QtCore import *
 from PySide.QtGui import *
 
-import geglqt as GeglQt
+from geglqt import GeglQt
 
 graph_xml = """
 <gegl>
@@ -41,7 +41,7 @@ if __name__ == '__main__' :
     Gegl.init(0,"")
     node = Gegl.Node.new_from_xml(graph_xml % file_path, "/");
 
-    view = GeglQt.GeglQt.NodeViewWidget()
+    view = GeglQt.NodeViewWidget()
     view.setInputNode(node.get_children()[-1])
     view.show()
 
diff --git a/gegl-qt.pro b/gegl-qt.pro
index bfe0d39..0aeed41 100644
--- a/gegl-qt.pro
+++ b/gegl-qt.pro
@@ -4,15 +4,25 @@ isEmpty(GEGLQT_CONFIG):error("config.pri not found")
 TEMPLATE = subdirs
 CONFIG += ordered
 
+# Subdirectories
 isEmpty(USE_EXTERNAL_GEGLQT) {
-    SUBDIRS += gegl-qt pygegl-qt operations plugins
+    SUBDIRS += gegl-qt
+    contains(HAVE_PYSIDE, yes) {
+        SUBDIRS += pygegl-qt
+    }
+    SUBDIRS += operations plugins
+
 } else {
     !system(pkg-config --exists $$GEGLQT_LIBNAME):error("Could not find required dependency: GEGL-QT")
 }
 SUBDIRS += examples tests
 
+# Check hard deps
 !system(pkg-config --exists gegl):error("Could not find required dependency: GEGL")
 
+
+### Extra targets for distribution ###
+
 DIST_NAME = $$GEGLQT_PROJECTNAME-$$GEGLQT_VERSION
 DIST_PATH = $$OUT_PWD/$$DIST_NAME
 TMP_PATH = /tmp/$$GEGLQT_PROJECTNAME-$$GEGLQT_VERSION
@@ -56,7 +66,3 @@ intcheck.commands += make check;
 
 OTHER_FILES = \
     README.txt gegl-qt.doap \
-    pygegl-qt/typesystem_gegl-qt.xml \
-    pygegl-qt/geglnode_conversions.h \
-    pygegl-qt/Makefile \
-
diff --git a/pygegl-qt/.gitignore b/pygegl-qt/.gitignore
index fbfe1ea..45c6ce6 100644
--- a/pygegl-qt/.gitignore
+++ b/pygegl-qt/.gitignore
@@ -1,2 +1,3 @@
-GeglQt
+geglqt
+Makefile
 mjb_rejected_*.log
diff --git a/pygegl-qt/pygegl-qt.pro b/pygegl-qt/pygegl-qt.pro
new file mode 100644
index 0000000..0b6c876
--- /dev/null
+++ b/pygegl-qt/pygegl-qt.pro
@@ -0,0 +1,76 @@
+include(../config.pri)
+
+TEMPLATE = subdirs
+
+QMAKE_EXTRA_TARGETS += first
+first.depends += generate compile link
+
+TYPESYSTEM_DIR = $$system(pkg-config pyside --variable=typesystemdir)
+
+LIBGEGLQT_SRC_DIR = ../gegl-qt
+PYSIDE_INCLUDE_DIR = $$system(pkg-config --variable=includedir pyside)
+HEADERDIR_QT = $$[QT_INSTALL_HEADERS]
+GEN_INCLUDE_PATHS = $$LIBGEGLQT_SRC_DIR:$$HEADERDIR_QT/QtCore:$$HEADERDIR_QT
+
+INCLUDES += \
+    -I.. \
+    -I$$LIBGEGLQT_SRC_DIR \
+    -I$$PYSIDE_INCLUDE_DIR/QtCore \
+    -I$$PYSIDE_INCLUDE_DIR/QtGui \
+    -I$$PYSIDE_INCLUDE_DIR/QtDeclarative \
+    -I$$PYSIDE_INCLUDE_DIR/QtNetwork \
+    -I$$[QT_INSTALL_HEADERS]/QtCore \
+    -I$$[QT_INSTALL_HEADERS]/QtGui \
+    -I$$[QT_INSTALL_HEADERS]/QtDeclarative \
+    -I$$[QT_INSTALL_HEADERS]/QtNetwork \
+
+INCLUDES += $$system(pkg-config --cflags gegl pygobject-2.0 gobject-2.0 pyside)
+
+# pkg-config --libs pyside is buggy for pyside<1.0.5 due
+# http://bugs.pyside.org/show_bug.cgi?id=929
+# PYSIDE_LIBS = /usr/lib/libpython2.7.so -L/usr/lib -lpyside-python2.7 -lshiboken-python2.7
+
+LIBRARIES += -L../gegl-qt -l$$GEGLQT_LIBNAME
+LIBRARIES += $$system(pkg-config --libs gegl pygobject-2.0 gobject-2.0 pyside)
+
+# Generate
+QMAKE_EXTRA_TARGETS += generate
+generate.target = generate
+generate.commands += generatorrunner --generatorSet=shiboken \
+                global.h \
+                --include-paths=$$GEN_INCLUDE_PATHS \
+                --typesystem-paths=.:$$TYPESYSTEM_DIR \
+                --output-directory=. \
+                typesystem_gegl-qt.xml
+
+# Compile
+QMAKE_EXTRA_TARGETS += compile
+compile.depends += generate
+compile.target = compile
+compile.commands += g++ -DNO_IMPORT_PYGOBJECT geglqt/geglqt_*.cpp $$INCLUDES -Wall -fPIC -c;
+compile.commands += g++ geglqt/geglqt_module_wrapper.cpp $$INCLUDES -Wall -fPIC -c
+
+# Link
+QMAKE_EXTRA_TARGETS += link
+link.depends += compile
+link.target = geglqt.so
+link.commands += g++ geglqt*wrapper.o $$LIBRARIES -fPIC -shared -Wl,-soname,geglqt.so -o geglqt.so
+
+# Install
+PYTHON_SITE_PACKAGES = $$system(`echo $PYTHON` -c \"from distutils.sysconfig import get_python_lib; print get_python_lib(True)\")
+isEmpty(PYTHON_SITE_PACKAGES) {
+    PYTHON_SITE_PACKAGES = $$system(python -c \"from distutils.sysconfig import get_python_lib; print get_python_lib(True)\")
+
+}
+
+QMAKE_EXTRA_TARGETS += install
+install.depends = geglqt.so
+install.files = geglqt.so
+install.path = $$PYTHON_SITE_PACKAGES
+
+INSTALLS += install
+
+OTHER_FILES += \
+    typesystem_gegl-qt.xml \
+    geglnode_conversions.h \
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]