{"id":2074,"date":"2016-05-04T10:50:18","date_gmt":"2016-05-04T08:50:18","guid":{"rendered":"https:\/\/www.opengis.ch\/?p=2074"},"modified":"2020-04-29T16:05:13","modified_gmt":"2020-04-29T14:05:13","slug":"qgis-qt5-and-python3-migration-current-state","status":"publish","type":"post","link":"https:\/\/www.opengis.ch\/de\/2016\/05\/04\/qgis-qt5-and-python3-migration-current-state\/","title":{"rendered":"QGIS: Qt5 and Python3 migration, current state"},"content":{"rendered":"<p>Behind the scenes a lot has happened to get ready for Qt5 and Python3. On the same codebase that is becoming the next release QGIS 2.16. This is really a great thing since we can focus work on a single master branch and I&#8217;m very happy that we got so far with this approach already.<\/p>\n<h2>Testing<\/h2>\n<p>At OPENGIS.ch we have\u00a0put a huge\u00a0effort into getting the Travis CI test infrastructure to test our code with Qt5 and Python 3. This gives us confidence that we don&#8217;t have regressions introduced once we declare Qt5 and Python 3 to be default. At the time of writing we have <a href=\"https:\/\/travis-ci.org\/qgis\/QGIS\/jobs\/127728328\">177 tests passing on Qt5\/Python3<\/a> vs\u00a0<a href=\"https:\/\/travis-ci.org\/qgis\/QGIS\/jobs\/127728327\">211 tests on Qt4\/Python2<\/a>. Most of the missing tests are caused by a single issue (PyQt5 and NULL, see below).<\/p>\n<h2>Migration tool<\/h2>\n<p>There is a <a href=\"https:\/\/github.com\/qgis\/QGIS\/blob\/master\/scripts\/2to3\">script 2to3<\/a> that takes care of migrating &#8222;old&#8220; python code to portable code. That means, after running this tool on your python code it is compatible with PyQt4, PyQt5, Python2 and Python3.<br \/>\nIt uses the <a href=\"https:\/\/python-future.org\/\">future library for python compatibility<\/a> and a custom qgis.PyQt module that takes care of importing from the appropriate PyQt4 or PyQt5 modules.<br \/>\nThis can be done on build for core plugins with a new cmake option We do this on our (travis) CI builds when building for Qt5.<br \/>\nPlease note that the tool does a very good job (kudos to J\u00fcrgen at this point) but it cannot do everything, so plugin developers will also need to test in-depth and we&#8217;ll need to also prepare a migration guide that lists things to manually take care of.<\/p>\n<h2>PyQt5<\/h2>\n<p>PyQt5 &#8211; just like Qt5 &#8211; is very similar to PyQt4. This is a good thing since it makes it easier to write portable code.<br \/>\nThe main issue which we have found so far is <a href=\"https:\/\/www.riverbankcomputing.com\/pipermail\/pyqt\/2016-April\/037300.html\">the lack of PyQtNullVariant<\/a> and without this we don&#8217;t have proper support for NULL values. Definitely a no-go. Or we use to a different handling of attributes which would mean major manual updates to all plugins, IMHO also a no-go. The good thing is,\u00a0there are good chances that PyQtNullVariant will be re-introduced in PyQt 5.7 but this means that our minimum Qt requirement will be Qt 5.7 which in turn means that older linux distros will be locked into using old QGIS versions.<\/p>\n<h2>Qt5<\/h2>\n<p>A lot of these updates have been done some time ago already. Qt5 (without python involved) runs quite painless. <a href=\"https:\/\/opengisch.github.io\/QField-docs\/\">QField<\/a>\u00a0wouldn&#8217;t run without it.<\/p>\n<h2>What&#8217;s left to do<\/h2>\n<ul>\n<li>Finding a solution for\u00a0the PyQt5 NULL issue<\/li>\n<li>Check which tests still fail after the issue has been fixed<\/li>\n<li><a href=\"https:\/\/github.com\/qgis\/qgis3.0_api\/issues\">Implement many\u00a0other changes<\/a>\u00a0which we want to work on before being able to ship\u00a0QGIS with a version number 3.0.<\/li>\n<li>Writing a migration guide<\/li>\n<\/ul>\n<h2>Building<\/h2>\n<p>If you are curious to test it, make sure you have the build dependencies (recent distros ship with Qt5 and Python3, so just apt-get, dnf, pacman or however them from the repositories)<br \/>\nHere the commands I use to build and run from the build directory (so you can do this on a system with other QGISes installed as well)<\/p>\n<pre class=\"lang:bash decode:true\">$ cmake -DENABLE_QT5=ON -DPORT_PLUGINS=ON ..\/QGIS\n$ make\n$ .\/output\/bin\/qgis\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Behind the scenes a lot has happened to get ready for Qt5 and Python3. On the same codebase that is becoming the next release QGIS 2.16. This is really a great thing since we can focus work on a single master branch and I&#8217;m very happy that we got so [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[31,6,12,14,15],"tags":[125],"class_list":["post-2074","post","type-post","status-publish","format-standard","hentry","category-cpp","category-gis","category-programming","category-python","category-qgis","tag-qgis-org"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":2059,"url":"https:\/\/www.opengis.ch\/de\/2016\/03\/23\/prepare-your-plugins-for-qgis-3\/","url_meta":{"origin":2074,"position":0},"title":"Prepare your plugins for QGIS 3","author":"Matthias Kuhn","date":"23. M\u00e4rz 2016","format":false,"excerpt":"QGIS 3 is not yet there and there is still plenty of time to prepare and migrate. But I thought I would give some advice about things that you can keep in mind while working on your plugins to make your life easier when you will have to actually do\u2026","rel":"","context":"In &quot;Uncategorised&quot;","block_context":{"text":"Uncategorised","link":"https:\/\/www.opengis.ch\/de\/category\/uncategorised\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1292,"url":"https:\/\/www.opengis.ch\/de\/2015\/01\/28\/qgis-mobile-is-now-qfield\/","url_meta":{"origin":2074,"position":1},"title":"A star is born, QGIS mobile is now QField","author":"Marco Bernasocchi","date":"28. Januar 2015","format":false,"excerpt":"It is with great pleasure that we want to announce the new name for what was briefly known as QGIS mobile. Please welcome QField for QGIS\u2122! QField is an Open Source field data capture and management app fully compatible with QGIS\u2122 which allows you to take your QGIS projects out\u2026","rel":"","context":"In &quot;QField&quot;","block_context":{"text":"QField","link":"https:\/\/www.opengis.ch\/de\/category\/gis\/qfield\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3691,"url":"https:\/\/www.opengis.ch\/de\/2018\/04\/13\/porting-qgis-plugins-to-api-v3-strategy-and-tools\/","url_meta":{"origin":2074,"position":2},"title":"Porting QGIS plugins to API v3 &#8211; Strategy and tools","author":"Marco Bernasocchi","date":"13. April 2018","format":false,"excerpt":"The Release of QGIS 3.0 was a great success and with the first LTR (3.4) scheduled for release this fall, it is now the perfect time to port your plugins to the new API. QGIS 3.0 is the first major release since September 2013 when QGIS 2.0 was released. During\u2026","rel":"","context":"In &quot;Featured&quot;","block_context":{"text":"Featured","link":"https:\/\/www.opengis.ch\/de\/category\/featured\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2127,"url":"https:\/\/www.opengis.ch\/de\/2016\/09\/19\/qgis2-compatibility-plugin\/","url_meta":{"origin":2074,"position":3},"title":"QGIS2 compatibility plugin","author":"Marco Bernasocchi","date":"19. September 2016","format":false,"excerpt":"Lately I've been spending time porting a bigger plugin from QGIS 2.8 to 3 while maintaining 2.8 compatibility. You can find it at https:\/\/github.com\/opengisch\/qgis2compat\/ and https:\/\/plugins.qgis.org\/plugins\/qgis2compat\/ One code to rule them all. My target was to have to edit the source code as little as possible to simulate a lazy\u2026","rel":"","context":"In &quot;PyQt&quot;","block_context":{"text":"PyQt","link":"https:\/\/www.opengis.ch\/de\/category\/programming\/python\/pyqt\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":15596,"url":"https:\/\/www.opengis.ch\/de\/2025\/05\/28\/qgis-industry-solutions-developer\/","url_meta":{"origin":2074,"position":4},"title":"QGIS &amp; Industry Solutions Developer\u00a0| 80 \u2013 100% (Remote)","author":"Marco Bernasocchi","date":"28. Mai 2025","format":false,"excerpt":"\ud83d\udda5\ufe0f\ud83d\ude80 Join OPENGIS.ch as a QGIS & Industry Solutions Developer! We\u2019re seeking a skilled C++ and Python developer to contribute to QGIS core, build plugins, and deliver custom geospatial solutions. Work remotely with a dynamic, open-source-focused team. Apply now to help shape the future of geospatial technology!","rel":"","context":"In &quot;Job Postings Archive&quot;","block_context":{"text":"Job Postings Archive","link":"https:\/\/www.opengis.ch\/de\/category\/jobs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/03\/image.png?fit=1200%2C1167&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/03\/image.png?fit=1200%2C1167&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/03\/image.png?fit=1200%2C1167&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/03\/image.png?fit=1200%2C1167&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2025\/03\/image.png?fit=1200%2C1167&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2021,"url":"https:\/\/www.opengis.ch\/de\/2016\/02\/04\/increasing-the-stability-of-processing-algorithms\/","url_meta":{"origin":2074,"position":5},"title":"Increasing the stability of processing algorithms","author":"Matthias Kuhn","date":"4. Februar 2016","format":false,"excerpt":"Processing just got a new testing framework to improve\u00a0the long-term stability of this important plugin. And you can help to improve it, even if you are not a software developer! This is yet another piece in our never-stopping crusade to improve the stability and quality of the best\u00a0desktop GIS on\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.opengis.ch\/de\/category\/programming\/cpp\/"},"img":{"alt_text":"pr","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2016\/02\/pr.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2016\/02\/pr.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2016\/02\/pr.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2016\/02\/pr.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"jetpack_shortlink":"https:\/\/wp.me\/pbdBtI-xs","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/posts\/2074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/comments?post=2074"}],"version-history":[{"count":1,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/posts\/2074\/revisions"}],"predecessor-version":[{"id":11143,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/posts\/2074\/revisions\/11143"}],"wp:attachment":[{"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/media?parent=2074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/categories?post=2074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/tags?post=2074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}