mirror of
https://github.com/thp/pyotherside.git
synced 2025-01-28 23:52:55 +08:00
pythonVersion: Return run-time Python version (Fixes #14)
This commit is contained in:
parent
84bc298b75
commit
30c0247a80
@ -215,6 +215,13 @@ plugin and Python interpreter.
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
|
||||
.. versionchanged:: 1.5.0
|
||||
Previously, :func:`pythonVersion` returned the compile-time version of
|
||||
Python against which PyOtherSide was built. Starting with version 1.5.0,
|
||||
the run-time version of Python is returned (e.g. PyOtherSide compiled
|
||||
against Python 3.4.0 and running with Python 3.4.1 returned "3.4.0"
|
||||
before, but returns "3.4.1" in PyOtherSide after and including 1.5.0).
|
||||
|
||||
QML ``PyGLArea`` Element
|
||||
------------------------
|
||||
|
||||
@ -1355,6 +1362,7 @@ Version 1.5.0 (UNRELEASED)
|
||||
|
||||
* Spport for `OpenGL rendering in Python`_ using PyOpenGL >= 3.1.0
|
||||
* New QML components: ``PyGLArea``, ``PyFBO``
|
||||
* :func:`pythonVersion` now returns the runtime Python version
|
||||
|
||||
Version 1.4.0 (2015-02-19)
|
||||
--------------------------
|
||||
|
@ -365,6 +365,25 @@ QPython::pluginVersion()
|
||||
QString
|
||||
QPython::pythonVersion()
|
||||
{
|
||||
if (SINCE_API_VERSION(1, 5)) {
|
||||
ENSURE_GIL_STATE;
|
||||
|
||||
PyObjectRef version_info(PySys_GetObject("version_info"));
|
||||
if (version_info && PyTuple_Check(version_info.borrow()) &&
|
||||
PyTuple_Size(version_info.borrow()) >= 3) {
|
||||
|
||||
QStringList parts;
|
||||
for (int i=0; i<3; i++) {
|
||||
PyObjectRef part(PyTuple_GetItem(version_info.borrow(), i));
|
||||
parts << convertPyObjectToQVariant(part.borrow()).toString();
|
||||
}
|
||||
return parts.join('.');
|
||||
}
|
||||
|
||||
// Fallback to the compile-time version below
|
||||
qWarning("Could not determine runtime Python version");
|
||||
}
|
||||
|
||||
return QString(PY_VERSION);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user