summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-11-12 08:52:09 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-11-12 14:25:27 -0300
commit178f81aa70711876fe492431ae32afa3538cf460 (patch)
tree08da3637fb25f36969e8e61daaf1700dc611dea6
parent655219636b1500e82d543914045f4cc7ba7db95f (diff)
downloadpyside-178f81aa70711876fe492431ae32afa3538cf460.tar.gz
pyside-178f81aa70711876fe492431ae32afa3538cf460.tar.xz
pyside-178f81aa70711876fe492431ae32afa3538cf460.zip
Added PySide attributes to specify current version, and Qt version.
Fixes bug: #454 Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--PySide/CMakeLists.txt4
-rw-r--r--PySide/QtCore/glue/qt_version.cpp5
-rw-r--r--PySide/QtCore/typesystem_core.xml5
-rw-r--r--PySide/__init__.py2
-rw-r--r--PySide/__init__.py.in5
-rw-r--r--tests/pysidetest/CMakeLists.txt1
-rw-r--r--tests/pysidetest/version_test.py17
7 files changed, 31 insertions, 8 deletions
diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt
index c4aaf64..d7030d8 100644
--- a/PySide/CMakeLists.txt
+++ b/PySide/CMakeLists.txt
@@ -8,8 +8,8 @@ include(PySideModules)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/global.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/global.h" @ONLY)
-execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py"
- "${CMAKE_BINARY_DIR}/PySide/__init__.py")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" @ONLY)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/private.py"
"${CMAKE_BINARY_DIR}/PySide/private.py")
diff --git a/PySide/QtCore/glue/qt_version.cpp b/PySide/QtCore/glue/qt_version.cpp
new file mode 100644
index 0000000..66f8c00
--- /dev/null
+++ b/PySide/QtCore/glue/qt_version.cpp
@@ -0,0 +1,5 @@
+QList<QByteArray> version = QByteArray(qVersion()).split('.');
+PyObject *pyQtVersion = Shiboken::makeTuple(version[0].toInt(), version[1].toInt(), version[2].toInt());
+
+PyModule_AddStringConstant(module, "__version__", qVersion());
+PyModule_AddObject(module, "__version_info__", pyQtVersion);
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index e542ea6..c5d3ac5 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -596,10 +596,7 @@
</inject-code>
</add-function>
- <inject-code class="target" position="end">
- PyModule_AddIntConstant(module, "QT_VERSION", QT_VERSION);
- PyModule_AddStringConstant(module, "QT_VERSION_STR", QT_VERSION_STR);
- </inject-code>
+ <inject-code class="target" position="end" file="glue/qt_version.cpp" />
<add-function signature="__moduleShutdown()">
<inject-code class="target" position="beginning">
diff --git a/PySide/__init__.py b/PySide/__init__.py
deleted file mode 100644
index c93c5df..0000000
--- a/PySide/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-__all__ = ['QtCore', 'QtGui', 'QtNetwork', 'QtOpenGL', 'QtSql', 'QtSvg', 'QtTest', 'QtWebKit', 'QtScript']
-import private
diff --git a/PySide/__init__.py.in b/PySide/__init__.py.in
new file mode 100644
index 0000000..f931fad
--- /dev/null
+++ b/PySide/__init__.py.in
@@ -0,0 +1,5 @@
+__all__ = ['QtCore', 'QtGui', 'QtNetwork', 'QtOpenGL', 'QtSql', 'QtSvg', 'QtTest', 'QtWebKit', 'QtScript']
+import private
+
+__version__ = "@BINDING_API_VERSION@"
+__version_info__ = (@BINDING_API_MAJOR_VERSION@, @BINDING_API_MINOR_VERSION@, @BINDING_API_MICRO_VERSION@)
diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt
index 176c8cd..d983ef8 100644
--- a/tests/pysidetest/CMakeLists.txt
+++ b/tests/pysidetest/CMakeLists.txt
@@ -63,4 +63,5 @@ add_dependencies(testbinding pyside QtCore libpyside pysidetest)
PYSIDE_TEST(homonymoussignalandmethod_test.py)
+PYSIDE_TEST(version_test.py)
diff --git a/tests/pysidetest/version_test.py b/tests/pysidetest/version_test.py
new file mode 100644
index 0000000..cb2b399
--- /dev/null
+++ b/tests/pysidetest/version_test.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+
+import unittest
+from PySide import __version_info__, __version__, QtCore
+
+class CheckForVariablesTest(unittest.TestCase):
+ def testVesions(self):
+ self.assert_(__version_info__ >= (1, 0, 0))
+ self.assert_(__version_info__ < (99, 99, 99))
+ self.assert_(__version__)
+
+ self.assert_(QtCore.__version_info__ >= (4, 5, 0))
+ self.assert_(QtCore.__version__)
+
+if __name__ == '__main__':
+ unittest.main()
+