[Qgis-user] Determining QGIS version on command line
Steve Malers
steve.malers at openwaterfoundation.org
Thu Mar 26 21:29:22 PDT 2020
QGIS list:
I have tried to find the answer for this and hope the user community can
help. I need a robust and consistent way to determine the QGIS version on
the command line that I can call from a bat file on Windows (and similar on
Linux), something like: qgis-bin.exe --version
Background: I am developing a complex Python tool that uses PyQGIS and
PyQt and is distributed as a virtual environment (venv) created using a
specific version of QGIS Python, for example QGIS 3.10 python37. The
deployed environment requires that QGIS is installed separately The run
script modifies its PYTHONPATH to include packages for PyQGIS and the
application. The venv includes a text file that indicates the QGIS version
that the venv was built with and verifies that a compatible QGIS is
installed. The run script properly handles the typical case where
stand-alone QGIS is installed because it looks at the file path, such as
C:\Program Files\QGIS 3.10. If it finds a match, then that version of QGIS
is used in PYTHONPATH and the application starts OK.
The problem is that if someone has not installed a stand-alone QGIS but has
installed OSGeo464 version (C:\OSGeo4W64), there is no indicator of QGIS
version in the installation folder. I cannot find documentation for
qgis-bin.exe command line options and experiments did not show support for
--version or variants. I could scrape the QGIS version from files
somewhere in the distribution but looking into the code it seems to get
complicated due to handoff from Python to C/C++ code. If I can determine
the version I can check to make sure that the OsGeo4W64 QGIS version
matches that of the distributed venv. Lacking this, the run script cannot
do the check. Supporting OSGeo4W64 is needed because some development and
deployed environments use it. My plan B is to write a simple Python
program to access the version from the Python side, making general
assumptions to get started, and then configure the main application startup.
Any help would be appreciated.
--
Steve Malers
Chief Executive Officer and Chief Technology Officer
Open Water Foundation
openwaterfoundation.org
Support the Open Water Foundation by selecting on smile.amazon.com
<https://smile.amazon.com/ch/46-2676240>
Open data. Open software. Open decisions.... with positive social impact.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20200326/e594fca9/attachment.html>
More information about the Qgis-user
mailing list