Tuesday, April 14, 2015

Spinning the old wheels

First off today, I spent some time nailing down what is happening with the cx_freeze bundle in Linux. Then I wrote what I hope is a detailed and constructive note to the cxfreeze list,

I am trying to freeze an app on Ubuntu 14.10. The app uses PyQt5 and runs under Python3.4

Cxfreeze creates a bundle into which it copies all the dependent libraries,
for example libQt5Core.so.5, libQt5Widgets.so.5, and so forth. It also
copies the PyQt libs such as PyQt5.QtCore.so, PyQt5.QtWidgets.so, etc.

When I move this bundle to another Ubuntu system where this version of Python
and Qt are not installed, I get the dreaded message,

      Cannot mix incompatible Qt library (version 0x50300) with this library (version 0x50401)
      Aborted (core dumped)


I think it is trying to load from the local Qt (Ubuntu has some version
of Qt installed by default). On that system, after copying the bundle
from the dev system, I see this:

    $ cd Desktop/PPQT2 # the bundle made by cxfreeze

    $ ldd libQt5Widgets.so.5
        linux-gate.so.1 =>  (0xb779c000)
        libQt5Gui.so.5 => /home/dcortesi/Desktop/PPQT2/./libQt5Gui.so.5 (0xb6b49000)
        libQt5Core.so.5 => /home/dcortesi/Desktop/PPQT2/./libQt5Core.so.5 (0xb6605000) 

       ...


That is good! libQt5Widgets is linking to the bundled copy of libQt5Gui and so on.

However:

    $ ldd PyQt5.QtWidgets.so
        linux-gate.so.1 =>  (0xb7776000)
        libQt5Widgets.so.5 => /usr/lib/i386-linux-gnu/libQt5Widgets.so.5 (0xb6afb000)


That is bad, PyQt5.QtWidgets is linking to the local native
libQt5Widgets -- NOT the one bundled right there alongside it.

Why is this? Am I doing something wrong? Or is something needed in the hooks for PyQt5?

Thanks for any help,

Until I get some help with that, I have no way to create a bundle on Linux.

Nor on MacOS either! I took the cx_freeze MacOS bundle to my wife's iMac where there's no Qt or Python and of course it didn't run; it dies looking for a Python in /usr/lib, I believe — I forget and I've deleted the evidence now. Anyway, something that should be in the bundle, probably is in the bundle, but that isn't where the app goes looking for it. Basically the same issue as on Linux.

I would really, really rather use py2app for MacOS anyway, as it almost makes a nice looking MacOS app object. But not quite. So I started trying to debug that code and spent a couple of hours on that. You want to see a nice detailed "issue"? Check this out. (edit: that's weird, there should be 5 comments on that, not 2, and the last 3 are very detailed debugging info.) No response from R. Oussoren yet.

It's an infuriating bug because it does not fail when run under the debugger. It only fails when running at speed from the command line.

Well, so cx_freeze is failing for MacOS and for Linux. And py2app is failing for MacOS. I haven't gotten around to trying it yet, but I don't have a lot of hope for py2exe on Windows. It claims now to support Python3, which is good, but its writeup doesn't say anything about Qt, which is ominous.

Back in V1 days, I didn't worry about all these other bundlers; I just used PyInstaller. I liked it so much I rewrote the manual for it, and I put in several days work doing the initial coding to move it to Python3 and start using Oussoren's ModuleGraph. That was more than a year ago.

Recently I got it kind of working on MacOS. But when I tried it on Linux I ran into problems that, it turns out, had already been fixed on the Python2, or main, branch. There's been quite a bit of maintenance applied in the year-plus since Python3 split off. So I wrote to one of the maintainers, and this was the reply,

> It appears my problem is trying to use the Python3 branch, and this
is missing maintenance since I don't know when, a year?

Yes, we are lagging behind a lot. development-branch advanced and 
modulegraph was merged with python3 somehow. This needs to be cleaned
up and merged/rebased - but this is a lot of work nobody has started yet.

So basically, I'm screwed. PyInstaller for Python3 is just unusable until someone does the job of merging all commits since early 2014, into the Python3 branch. I have no idea what-so-ever how to do that. None. And the people who presumably do have a clue, are too busy.

Things are not looking good on the bundling front, frankly. And without a reliable way of making standalone, independent bundles on all three platforms, I don't have a product.

Thursday I will hack away at the Windows installation, installing the needed visual C, and then py2exe, and maybe that'll work. Maybe the cx_freeze crew will have a suggestion that will fix it on both MacOS and Linux. (and maybe... never mind)

No comments: