Qt5 WebEngine and Python3

Anke Boersma demm at kaosx.us
Sun Sep 27 16:15:12 BST 2020


On Sun, Sep 27, 2020 at 10:53 AM Adriaan de Groot <groot at kde.org> wrote:

> Hi distro-peeps,
>
> If you, like me, are concerned about Qt5 WebEngine and how that is
> supposed to
> handle the deprecation of Python2 -- with all of Google's wretched build
> system and internals embedded inside -- then a port to Python3 is
> necessary,
> if only to keep Qt5 5.15.1 building after Python 2.7 really goes away.
>
> I sat down for two weekends -- if KDE could build a better CORBA in one
> weekend (it did) and create an entire Free Software web renderer (it did)
> then
> surely fixing the demon offspring of our own web thing is also doable. The
> results are in the FreeBSD port as one big patch to the Python bits of the
> qt5-webengine tarball; apply them after configure.
>
> The port lives here:
>
>
> https://github.com/freebsd/freebsd-ports-kde/tree/webengine-python3/www/qt5-webengine/
>
> the patches are either `python-patches.diff` or `files/python3-build.diff`
> depending on when you look at it; file history of the patch is really
> crappy
> because it's me running the webengine build a zillion times, cursing the
> Google management that hasn't updated their scripts consistently, or at
> all,
> for 12 years.
>
> Status:
>
> - it builds, 100%, and gives a webengine that can render web content (e.g.
> reading planet.kde.org)
> - the JS engine is missing some methods; it may be because of sorting
> issues
> that APIs have gotten muddled or wrong. For instance, I get this kind of
> stderr output:
>
> js: Uncaught (in promise) TypeError: Failed to execute 'setTimeout' on
> 'Window': No function was found that matched the signature provided.
> qml: Loading changed for request url : https://www.google.com/
>
> <Unknown File>: Can't create role for unsupported data type
> js: Uncaught TypeError: Failed to execute 'postMessage' on 'Window': No
> function was found that matched the signature provided.
>
> - the patch is rife with fix-it-now kind of bodges; ideally I'd go back
> and
> understand the tooling better and re-build with a consistent type system,
> but
> honestly, I'm not being paid for this shit
>
>
> What I'd like from distro's:
>
> - give the patch a shot, drop python 2.7 from your webengine build and do
> it
> with Python3
> - if you have cycles to spare (both brain and CPU), looking into the
> difference between available JS in the two builds would be a big boon.
>
> Obvious improvements:
> - sorting of lots of the generated C++ output (jinja2 to generate c++ to
> compile later .. monstrous) has gone away, e.g. around line 559
>
> -{% for tag in tags|sort if not tag.multipleTagNames and not
> tag.noTypeHelpers
> %}
> +{% for tag in tags if not tag.multipleTagNames and not tag.noTypeHelpers
> %}
>
>   After dealing with this a dozen times, I now know that
> sort(attribute=name)
> is probably what's intended there and it makes the output more like the
> Python2.7 version.
> - some internal (i hope) enums are re-ordered, that's another thing to
> chase
> sorting for
>
>
> Since FreeBSD is removing Python 2.7 from the ports and packages in
> december,
> and has marked webengine as deprecated because of this, I thought it was
> time
> to get things done. It's at about .. mm .. 66%, because I reckon the
> wrangling
> for JS is going to take another weekend and even with massive ccache and
> memfs
> builds are neither pleasant nor fast.
>
> [ade]


To make the patch apply, one section had to be adjusted to work on plain
qtwebengine-everywhere-src-5.15.1:
---
./src/3rdparty/chromium/third_party/blink/renderer/build/scripts/rule_bison.py.orig
2020-09-27 11:22:21.680632451 +0200
+++
./src/3rdparty/chromium/third_party/blink/renderer/build/scripts/rule_bison.py
2020-09-27 11:22:21.592632443 +0200
@@ -88,7 +88,7 @@
 for outputHTry in outputHTries:
     try:
         os.unlink(outputHTry)
-    except OSError, e:
+    except OSError as e:
         if e.errno != errno.ENOENT:
             raise

@@ -104,7 +104,7 @@
         os.stat(outputHTry)
         outputHTmp = outputHTry
         break
-    except OSError, e:
+    except OSError as e:
         if e.errno != errno.ENOENT:
             raise

@@ -122,12 +122,11 @@
 outputHInGen = outputH.replace('gen/', '')
 headerGuard = NameStyleConverter(outputHInGen).to_header_guard()

-outputHFile = open(outputH, 'w')
-print >>outputHFile, '#ifndef %s' % headerGuard
-print >>outputHFile, '#define %s' % headerGuard
-print >>outputHFile, outputHContents
-print >>outputHFile, '#endif  // %s' % headerGuard
-outputHFile.close()
+with open(outputH, 'w') as outputHFile:
+    outputHFile.write( '#ifndef %s\n' % headerGuard )
+    outputHFile.write( '#define %s\n' % headerGuard )
+    outputHFile.write( outputHContents )
+    outputHFile.write( '\n#endif  // %s\n' % headerGuard )

 common_replace_list = [(inputRoot + '.hh',
                         inputRoot + '.h')]

With the above change build will start, but there is nothing yet set with
that patch to use python3, seem freebsd uses a custom Makefile to move to
python3:
https://github.com/freebsd/freebsd-ports-kde/blob/webengine-python3/www/qt5-webengine/Makefile#L143
https://github.com/freebsd/freebsd-ports-kde/blob/webengine-python3/www/qt5-webengine/files/patch-configure.pri

Anke Boersma
demm at kaosx.us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/distributions/attachments/20200927/e8ae6918/attachment.htm>


More information about the Distributions mailing list