Hi Jiri,

Thanks for thinking this through in detail.

I'm still planning a release to be made in April, prefer to start on that
code base. Current status here:
https://code.launchpad.net/~jaap.karssenberg/zim/zim-refactor will make it
pass test suite again next week, after that smaller patches until release.
Will do an export to github when I reach the point all tests pass again.

Also I will take the task to further untangle the main gui modules such
that it becomes easier to port module by module. Basically will move out
more core functions to plugins that can be loaded ad hoc. And I should
probably help cleaning up the code documentation: current API docs do not
compile, so want to convert to spinx and get them back online.

With respect to type hints I have no experience, but willing to give it a
go. My tooling is pretty basic, just a code editor and a unix shell :)

For the last phase there is also a pygtk to gi script available. Not even
close to full conversion, but handles the basic search and replace to start
with. Could be helpful.

Per phase we should probably keep track of who-is-doing-what to avoid
difficult merges. And we need to set up a smaller mail group to coordinate
the work with a low threshold of asking detail questions on the code base.
Maybe both can be facilitated through the github issue tracker ?

Regards,

Jaap


On Mon, Mar 20, 2017 at 3:45 PM Jiří Janoušek <janousek.j...@gmail.com>
wrote:

> Hello Jaap,
>
> I would prefer to port to both GTK 3 and Python 3 in one go (2) after
> a thorough preparatory phase (1). Here are my thoughts:
>
> (1) The first phase - Forward-compatible Python 2.7
>
> # Goal:
>
> To make the Python 2 codebase as much forward compatible with Python 3
> as possible, identify tricky code and (for me) to get familiar with
> the codebase.
>
> # Key requirements:
>
> - Zim is stable and fully functional.
> - It is still possible to add new features, fix bugs and make releases.
> - A working branch (py27?) can be regularly merged to the trunk after
> a code review.
>
> # Plan
>
> a) We should study the incompatibilities between Python 2 and 3 (e.g.
> [1][2]) and review the whole Zim codebase file by file. If the
> incompatibility can be solved with a forward-compatible Python 2.7
> code (e.g. `except KeyError as e:` istead of `except KeyError, e:`),
> port it immediately. Otherwise mark it with `# py2!` (optionally with
> a description).
>
> [1]: http://python-future.org/compatible_idioms.html
> [2]: http://python3porting.com/
>
> b) We should use `from __future__ import ...` features such as
> print_function, unicode_literals, division and absolute_import.
>
> c) We may run Zim with `python -3` option to enable extra warnings.
>
> d) We should port Zim to the new PyGTK 2.24 APIs (e.g. widget.window →
> widget.get_window(), container.child → container.get_child(), etc.) to
> make it compatible with PyGTKCompat [3].
>
> [3]: https://wiki.gnome.org/Projects/PyGObject/PyGTKCompat
>
> e) I propose using a Python-2 compatible variant of type hints [4][5].
> I use them a lot in my Python 3 + GTK+ 3 project at work and they have
> proved to be really useful as the PyCharm IDE supports them quite well
> (including the free Community Edition). It can even generate
> type-checking stubs for GTK+. I don't know what is your tooling but
> the mypy type checker can be used independently. There is no extra
> run-time dependency as the typing module is necessary only during the
> static type analysis.
>
> [4]: http://mypy.readthedocs.io/en/latest/python2.html
> [5]: https://www.python.org/dev/peps/pep-0484/
>
> If you are not fond of the type annotations, we may strip them off
> easily after porting (regex "#\s*type:\s+.*$"). However, I believe the
> annotations will help me to get familiar with the code and should spot
> some (but not all) errors without the need to run Zim again and again.
>
> # Outcome
>
> After this first phase, we will have a fully functional Python 2.7
> version of Zim. We may even keep it around as a LTS release for users
> who cannot switch to Python 3.
>
> (2) The second phase - Python 3 and GTK 3 port
>
> # Goal
>
> To port Zim to Python 3 and Gtk3 in one go
>
> # Plan
>
> - Decide on a minimal Python 3 and GTK+ 3 version. Python 3.4 is
> available in Debian Jessie and Ubuntu 14.04 LTS, Python 3.5 in Debian
> Stretch and Ubuntu 16.04 LTS.
> - A new branch is created.
> - All plugins and non-essential modules are disabled.
> - We may try to run Python's 2to3 script. I don't know how useful it
> actually is.
> - All code marked with # py2! is ported manually.
> - PyGTKCompat [3] module is used to get the app running fast and then
> GUI is ported flle-by-file to PyGObject GTK+ 3.
>
> Best regards,
>
> Jiri Janousek
>
> On Tue, Mar 14, 2017 at 12:22 PM, Jaap Karssenberg
> <jaap.karssenb...@gmail.com> wrote:
> > Hi Jiri,
> >
> > Would like to take you on on that offer. I will set up a branch to be
> used
> > for porting (I have a preferred starting point, not current trunk).
> >
> > Strategy wise I believe we need to go to Gtk3 before we can go to
> Python3,
> > so that will be 2 phases.
> > For the first step going to Gtk3 I would like to split up the
> application in
> > modules. Trying to get the basic application running first, than port
> > additional modules and plugins one-by-one.
> >
> > Let's simply use a wiki page to track progress and who-does-what. I
> prefer
> > (private) email for quick questions / discussions.
> >
> > Is this what you had in mind?
> >
> > Regards,
> >
> > Jaap
> >
> >
> > On Sat, Mar 11, 2017 at 7:39 PM Jiří Janoušek <janousek.j...@gmail.com>
> > wrote:
> >>
> >> > Yes, I have plans to port zim to python 3, but can't commit to a
> >> > concrete
> >> > timeline on this moment.
> >>
> >> I might help with the porting to Python 3 & GTK+ 3. What is the best
> >> place to discuss the strategy? Mailing list, bug tracker or Launchpad
> >> blueprints? I prefer the bug tracker.
> >>
> >> Best regards,
> >>
> >> Jiri Janousek
> >>
> >> _______________________________________________
> >> Mailing list: https://launchpad.net/~zim-wiki
> >> Post to     : zim-wiki@lists.launchpad.net
> >> Unsubscribe : https://launchpad.net/~zim-wiki
> >> More help   : https://help.launchpad.net/ListHelp
>
> _______________________________________________
> Mailing list: https://launchpad.net/~zim-wiki
> Post to     : zim-wiki@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~zim-wiki
> More help   : https://help.launchpad.net/ListHelp
>
_______________________________________________
Mailing list: https://launchpad.net/~zim-wiki
Post to     : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp

Reply via email to