From ce4eb22a89f5e1f6c170031d2bd158764132b9f4 Mon Sep 17 00:00:00 2001 From: Marco Bernasocchi Date: Fri, 13 Apr 2018 12:01:08 +0200 Subject: [PATCH] updated the whole guide to use qgis2to3 --- Plugin-migration-to-QGIS-3.md | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/Plugin-migration-to-QGIS-3.md b/Plugin-migration-to-QGIS-3.md index 15ec0db..2f31260 100644 --- a/Plugin-migration-to-QGIS-3.md +++ b/Plugin-migration-to-QGIS-3.md @@ -7,32 +7,30 @@ In QGIS 3, GeoPackage is much more present. Avoid creating shapefile in your plu ## Minimal info - `pip install future` -- [git checkout the source tree](https://htmlpreview.github.io/?https://raw.github.com/qgis/QGIS/master/doc/INSTALL.html#toc9) and run QGIS/scripts/2to3 (https://github.com/qgis/QGIS/blob/master/scripts/2to3) on your plugin - - `path/to/QGIS/scripts/2to3 /path/to/your/plugin` +- `pip install qgis2to3` (docs [github.com/opengisch/qgis2to3](https://github.com/opengisch/qgis2to3)) +- `qgis2to3 /path/to/my/plugin` - This command will print the diff. If you want to write these changes to files, use `-w` - The script will automatically update from Py2 to Py3, from Qt4 to the correct PyQt version. For instance `from PyQt4.QtGui import QMainWindow` will become `from qgis.PyQt.QtWidgets import QMainWindow`. - - The script will update some QGIS API changes. -- have a good look at: https://qgis.org/api/api_break.html -- make sure you do python3 and Qt5 ! + - The command will update some QGIS API changes. +- `qgis2apifinder /path/to/my/plugin` + - This will show you potential api v2 only usages (as listed on https://qgis.org/api/api_break.html) +- set `qgisMinimumVersion=3.0` in metadata.txt +- make sure you do python3 and Qt5! - tweak and fix until it works :-) -It was more work then I hoped, but after setting +You should see your plugin in QGIS 2.99 and up (*note: if it does not appear, make sure your build is newer than 4.01.2018, as there was an important change 3.01.2018 17:09 UTC: https://github.com/qgis/QGIS/pull/5904*) -``` -qgisMinimumVersion=3.0 -``` - -in metadata you should see your plugin in QGIS 2.99 and up (*note: if it does not appear, make sure your build is newer than 4.01.2018, as there was an important change 3.01.2018 17:09 UTC: https://github.com/qgis/QGIS/pull/5904*) - -You can find Python API documentation at http://python.qgis.org/api/ (work in progress). +You can find Python API documentation at http://python.qgis.org/master/ **Please note**: QGIS3 compatibility module (so 3.x plugins will also work on 2.18) has been deprecated. -## Python plugin issues +## Debugging and finding problems +You can use the [qgis2to3](http://www.opengis.ch/2018/04/13/porting-qgis-plugins-to-api-v3-strategy-and-tools/) tools and your IDEs (PyCharm or Eclipse) to step through your code and find and solve incompatibilities. +Alternatively, you can install First Aid plugin and use it within QGIS. More info can be found here: https://www.lutraconsulting.co.uk/blog/2016/06/12/introducing-first-aid-plugin/ + +## Other possible issues Python plugin issues QGIS 3 MetaSearch user migration: problems with Python plugins? Clear out your *.pyc files (so QGIS Python can compile via Python 3). -## Debugging and finding problems -You can use IDEs (PyCharm or Eclipse) to step through your code. Alternatively, you can install First Aid plugin and use it within QGIS. More info can be found here: https://www.lutraconsulting.co.uk/blog/2016/06/12/introducing-first-aid-plugin/ - ## More info * https://gisforthought.com/updating-a-plugin-from-qgis-2-to-qgis-3/ -* https://github.com/gc-i/wntOS/wiki/QGIS3Port \ No newline at end of file +* https://github.com/gc-i/wntOS/wiki/QGIS3Port +* http://www.opengis.ch/2018/04/13/porting-qgis-plugins-to-api-v3-strategy-and-tools/ \ No newline at end of file