[GRASS-dev] [SoC] Week 13 - Final Report - Full support of Python 3 in GRASS GIS

Sanjeet edu.sanjeet at gmail.com
Mon Aug 13 22:36:27 PDT 2018


Hi everyone,

This is my Week 13 final report for the GSoC project "Full support of Python
3 in GRASS GIS"

--

Title: Full support of Python 3 in GRASS GIS
Community: GRASS GIS - OSGeo

Abstract:
This project updates the GRASS GIS software to support Python 3, where
earlier it only worked with the Python 2.7 version. All the libraries,
modules and components of the system have been updated to include the
latest changes that have been introduced in Python 3. One of the
important updates was a way to deal with unicode and bytes strings
that helped in making GRASS compatible with both the versions of
Python by properly encoding and decoding the strings. Additionally,
the ctypes library, which was only working with Python 2.7, has been
upgraded to deal with Python 3 which further helped in modifying the
temporal and pygrass libraries. The pydispatch and guinittest modules
have also been altered to properly deal with unicodes while the
trunk/scripts have been modified and tested by writing new testsuites
for them. The GUI module of GRASS is built with wxPython Classic
version, which now with the help of wrapper classes works well with
the latest wxPython 4 - Phoenix version.

The state of the art BEFORE the start of GSoC:
Before the start of the project, GRASS GIS had partial support for
Python 3. The ctypes library failed to compile with Python 3 while a
lot of code in other modules was also incompatible with Python 3
syntax. The GUI module worked with wxPython 3 (Classic version) but
not with the latest wxPython 4 (Phoenix). There were a lot of
assertion errors and deprecated code warnings that were seen when
GRASS was coupled with the wxPython 4.

The state of the art AFTER GSoC:
After the GSoC, GRASS can now be compiled with Python 3 version. The
different libraries and components of GRASS have been updated and are
thus compilable with Python 3.
The GUI module now has support for both the versions of wxPython, i.e.
Classic (3 or older) and Phoenix (4).

Challenges:
The biggest challenge in updating GRASS was dealing with the ‘ctypes’
library. The official library has not been updated since some time now
and the Python 3 support is not complete. It was a major hurdle to get
the 'ctypes' working in GRASS to compile other modules/libraries that
are dependent on this library. After making the desired changes in the
library, the GRASS system is able to compile but there are some
lingering issues that make it hard to fix other errors that persist in
the temporal and pygrass libraries.

Next Steps:
The next step would be to discuss ‘ctypes’ issue in further detail
with mentors and the development community. Even though some issues
related to ctypes have been solved in this project, it still requires
some significant efforts and time to make it fully compatible with all
Python versions. Moreover, fixing ctypes will help in solving all the
remaining issues in other GRASS modules that are closely dependent on
this library.

Permanent Links:
Code Repository for GSoC:
https://github.com/sanjeetbhatti/FullSupportPython3

Weekly Reports:
https://trac.osgeo.org/grass/wiki/GSoC/2018/FullSupportPython3

Python 2 - 3 and wxPython compatibility guidelines for developers:
https://trac.osgeo.org/grass/wiki/Python3Support

Image for project representation:
https://raw.githubusercontent.com/sanjeetbhatti/FullSupportPython3/master/GSoC-final-report-project-pic.png

Thanks,
Sanjeet


More information about the grass-dev mailing list