[qutebrowser] Qt 6 branch merged (but still Qt 5 by default)!

Florian Bruhin me at the-compiler.org
Sat Mar 18 22:07:52 CET 2023


Hey,

This week, @toofar and I worked together to fix some of the remaining
Qt 6 issues. Some users (including us two) have been using the Qt 6
branch for months, and for a long time, the remaining issues have been
more on the development side of things.

After hopping on a call (for the first time ever!), we found a nice way
forward: I'll merge the Qt 6 branch (qt6-v2), but with Qt 5 still being
set as the default, and then we can take things from there.

This avoids having two different development branches which needed to be
kept in sync, and - even if we keep Qt 5 as default - gets us much
closer to our Qt 6 goal, getting almost a year of work merged back to
master.

We're aiming for this to be as low-impact as possible: Right now, this
will only impact users running qutebrowser from git, and *almost*
nothing should change - but it's difficult to say with a year of
changes and over 300 commits! Things look a bit different for
contributors, more about this below.

--------------------------------------------------------------------------

For users running from git, here are the most important things to be
aware of:

- The qt6-v2 branch is deprecated. Once packagers switched away from it,
  we'll probably push a final commit making people aware of that with a
  warning, and then at some point remove it.
- Instead, if you're running Qt 6 now, switch to the new master branch,
  and set QUTE_QT_WRAPPER=PyQt6 somewhere in your environment.
  Alternatively, continue using a -qt6 package, we're hoping for
  packagers to adjust via patching the default backend there.
- If you end up accidentally downgrading from running Qt 6 to Qt 5,
  the underlying Chromium will discard your browsing data (such as
  cookies). qutebrowser will warn about this while starting, but if you
  confirm, it will happily oblige. It might be advisable to backup your
  ~/.local/share/qutebrowser/webengine (or whatever your data directory
  is, see :version).
- Support for Qt/PyQt before 5.15.0 and QtWebEngine before 5.15.2 are
  now dropped, as older Qt versions are end-of-life upstream since mid/late
  2020 (5.13/5.14) and late 2021 (5.12 LTS): https://endoflife.date/qt

--------------------------------------------------------------------------

For packagers, there are only really two changes to keep in mind:

- Switch from qt6-v2 to master, and instead patch the _DEFAULT_WRAPPER
  in qutebrowser.qt.machinery:
  https://github.com/qutebrowser/qutebrowser/blob/master/qutebrowser/qt/machinery.py

  Something like this should do:
  sed -i 's/_DEFAULT_WRAPPER = "PyQt5"/_DEFAULT_WRAPPER = "PyQt6"/' qutebrowser/qt/machinery.py

- The icons moved from icons/ to qutebrowser/icons/:
  https://github.com/qutebrowser/qutebrowser/commit/e9ed6456fd38abe6d9269bb4f3842c95dc11dfba

--------------------------------------------------------------------------

For contributors, there are a couple of things to keep in mind:

Most importantly, this change introduces a *lot* of mechanical rewrites,
due to:

a) PyQt now requiring fully-qualified enum access:
https://github.com/qutebrowser/qutebrowser/issues/5904
https://github.com/qutebrowser/qutebrowser/commit/0877fb0d78635692e481c8bde224fac5ad0dd430
https://github.com/qutebrowser/qutebrowser/blob/master/scripts/dev/rewrite_enums.py

b) All our imports now having a redirection via qutebrowser.qt, in
order to dynamically decide wether to import Qt 5 or Qt 6:
https://github.com/qutebrowser/qutebrowser/commit/d47cfd99d7374a41b4c228c21221c7850e65d0b1
https://github.com/qutebrowser/qutebrowser/blob/master/scripts/dev/rewrite_qt_imports.sh

We're aware this is annoying - some PRs have been sitting around for
*way* too long, and this won't help the situation. After collecting some
data on mergeability, we decided to proceed with the absolute minimum of
changes we can get away with:
https://github.com/qutebrowser/qutebrowser/pull/7470

There is more I'd like to do (e.g. run black, and some other
autoformatters, especially because the changes messed up the formatting
in various places now). In the interest of not making things worse,
I'm still holding that off for now, until I can take another stab at the
PR backlog (hoping for that to happen in April).

If you want to adjust your PR yourself to merge again, the scripts above
*might* help. But they are not really production-ready at this stage I'm
afraid. If someone wants to work on improving them, that would be most
welcome!

However, I'm also completely okay with us picking up the lose ends while
working through the PR backlog and merging things. I'm still hoping I
can resume work on that front soon. Priority is on getting 3.0.0 out of
the door, but between April and September I'll be back on lots of
qutebrowser work, and the PR backlog will be a big part of that!

For a long time, I wanted to wait with merging Qt 6 stuff until I got
some more PRs in, but the parallel work in two branches made things a
lot more difficult for me as well. So I believe this is the right step
to take to get us out of this deadlock finally...

Of course, we're also happy to help if you run into trouble - both
toofar and I are active in the qutebrowser IRC:
https://github.com/qutebrowser/qutebrowser/blob/master/doc/help/index.asciidoc#getting-help

If you need to do any backend specific behavior there are bools in
qutebrowser.qt.machinery that you can use in conditionals:
https://github.com/qutebrowser/qutebrowser/blob/master-qt6/qutebrowser/qt/machinery.py
(PySide isn't actually supported yet)

Type hints are targeted at PyQt5 for now, since they were mostly working
already. We plan to switch to PyQt6 soon (5.15 is almost EOL already).

There are mypy-pyqt5 and mypy-pyqt6 environments in tox.ini which
configure mypy appropriately. See the contributing docs for details:
https://github.com/qutebrowser/qutebrowser/blob/master-qt6/doc/contributing.asciidoc
Similarly, there are new pyXY-pyqt6Z environments too.

Finally, Qt itself had various changes. The most important one is
probably some things moving from PyQtWebEngineWidgets to
PyQtWebEngineCore: https://doc.qt.io/qt-6/qtwebengine-changes-qt6.html

Our qutebrowser.qt wrappers adjust for that, and always use the new
locations/names:
https://github.com/qutebrowser/qutebrowser/blob/master/qutebrowser/qt/webenginecore.py

--------------------------------------------------------------------------

This is only the first big step. The next one will be flipping the
switch over from Qt 5 to Qt 6 for git users, and then finally getting
everything ready for the 3.0.0 relase. There are still some other things
to tackle for that:
https://github.com/qutebrowser/qutebrowser/issues?q=is%3Aopen+is%3Aissue+milestone%3Av3.0.0

But to avoid getting lost in even more stuff to do, we moved various
less important things to a 4.0.0 release, intended to come rather
quickly after 3.0.0 is finally out:
https://github.com/qutebrowser/qutebrowser/issues?q=is%3Aopen+is%3Aissue+milestone%3Av4.0.0
(this was only a first sweep, we might end up moving more)

Even if the default is Qt 5 still, I'd highly recommend to switch to
Qt 6 already - pretty much everything should work better at this point,
the only reason we didn't do that yet is some "ergonomics" around
switching/detecting Qt versions (e.g. error handling during imports,
seeing why the given version was selected, etc.).

The number one priority right now is getting Qt 6 out to every user,
given that more and more people have been running into compatibility
issues with the (arguably now ancient) Chromium 83/87 based Qt 5.

Starting Monday, I'll be abroad giving a Python company training until
the 30th, but given the amount of testing the branch has gotten, we
believe this should go smoothly.

Last, but certainly not least: Thanks to all the contributors for your
patience in this giant migration, and special thanks to everyone
contributing to or testing Qt 6 stuff.

Even more special thanks to @toofar, who did amazing work on a variety
of Qt 6 things, and came up with a great idea on how to move things
forward.

Phew. Time to send off this mail, and for a big shiny "git push":

339 files changed, 14152 insertions(+), 4598 deletions(-)
(to be fair, ~8000 lines is an enums.txt for the migration script)

Onwards, full steam ahead towards Qt 6!

Florian

-- 
            me at the-compiler.org | https://www.qutebrowser.org 
       https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
       GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
             I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://listi.jpberlin.de/pipermail/qutebrowser/attachments/20230318/6e5ef6f6/attachment.asc>


More information about the qutebrowser mailing list