PyQt4 and Qt plugins (imageformats, etc.) fully supported now

341 views
Skip to first unread message

Giovanni Bajo

unread,
Feb 23, 2009, 6:33:11 AM2/23/09
to PyInstaller ML, PyQt mailing list
Hello,

I've just added a new feature to PyInstaller: a module hook is now able
to specify additional data files that are needed for the module to work
correctly. Those data files are automatically collected when using
--onedir, or bundled within the executable when using --onefile (and
automatically extracted into the temporary dir at startup).

Using this support, I've improved PyQt4's import hooks so that Qt
plugins (such as imageformats, codecs, etc.) are automatically handled
by PyInstaller. IOW, this is now fully transparent to PyInstaller users:
just run PyInstaller trunk and enjoy your multi-platform bundles of PyQt
applications without having to take care of plugins manually.

NOTE: you will need to regenerate your .spec files for this new feature
to work.
--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com


Giovanni Bajo

unread,
Feb 25, 2009, 8:15:54 AM2/25/09
to Thorsten Kampe, py...@riverbankcomputing.com, pyins...@googlegroups.com
On 2/25/2009 12:55 AM, Thorsten Kampe wrote:
> * Giovanni Bajo (Mon, 23 Feb 2009 12:33:11 +0100)

>> I've just added a new feature to PyInstaller: a module hook is now
>> able to specify additional data files that are needed for the module
>> to work correctly. Those data files are automatically collected when
>> using --onedir, or bundled within the executable when using --onefile
>> (and automatically extracted into the temporary dir at startup).
>>
>> Using this support, I've improved PyQt4's import hooks so that Qt
>> plugins (such as imageformats, codecs, etc.) are automatically handled
>> by PyInstaller. IOW, this is now fully transparent to PyInstaller
>> users: just run PyInstaller trunk and enjoy your multi-platform
>> bundles of PyQt applications without having to take care of plugins
>> manually.
>
> Thanks. I've just downloaded the svn version and compiled a PyQt script.
> I got a lot of "W: library python%s%s required via ctypes not found"
> errors (although everything seems to work). Is that a known issue?

It's basically a false positive.

PyInstaller now automatically handles ctypes dependencies (eg: if you
use ctypes to access a custom dynamic library, it will be automatically
bundled by PyInstaller).

We're planning some ways to whitelist spurious PyInstaller warnings at
least in Python's own standard library.

Antonio Valentino

unread,
Feb 27, 2009, 9:21:25 AM2/27/09
to PyInstaller

On 23 Feb, 12:33, Giovanni Bajo <ra...@develer.com> wrote:
> Hello,
>
> I've just added a new feature to PyInstaller: a module hook is now able
> to specify additional data files that are needed for the module to work
> correctly. Those data files are automatically collected when using
> --onedir, or bundled within the executable when using --onefile (and
> automatically extracted into the temporary dir at startup).
>
> Using this support, I've improved PyQt4's import hooks so that Qt
> plugins (such as imageformats, codecs, etc.) are automatically handled
> by PyInstaller. IOW, this is now fully transparent to PyInstaller users:
> just run PyInstaller trunk and enjoy your multi-platform bundles of PyQt
> applications without having to take care of plugins manually.

Hi Giovanni,
I'm trying the new pyinstaller-trunk on my PyQt based project.
The new hoks seems to fail collecting Qt4 plugins because

hooks.hookutils.qt4_plugins_dir()

returns

"C:\Qt\4.4.1\plugins"


while the correct plugins location on my system is

"C:\Python25\Lib\site-packages\PyQt4\plugins"

I don't have Qt4 installed. I just used the standard PyQt4 installer
provided by riverback.
It seems to me a PyQt4 build issue and i can't figure out wich is the
best approach to solve this problem.

Do you have any idea?

Meanwhile I solved forcing the "pdir" variable in hook-PyQt4.QtGui.py.

ciao

--
Antonio Valentino

Giovanni Bajo

unread,
Feb 27, 2009, 10:24:51 AM2/27/09
to PyIns...@googlegroups.com

It looks like PyQt's installer installs a qt.conf file specifying the
plugin paths. Can you find a way to query that directory without having
to parse qt.conf?

Antonio Valentino

unread,
Feb 27, 2009, 12:33:14 PM2/27/09
to PyIns...@googlegroups.com
----- Original Message -----
From: "Giovanni Bajo" <ra...@develer.com>
To: <PyIns...@googlegroups.com>
Sent: Friday, February 27, 2009 4:24 PM
Subject: [PyInstaller] Re: PyQt4 and Qt plugins (imageformats, etc.) fully
supported now


> On 2/27/2009 3:21 PM, Antonio Valentino wrote:
>>
>> On 23 Feb, 12:33, Giovanni Bajo <ra...@develer.com> wrote:
>>> Hello,
>>>
>>> I've just added a new feature to PyInstaller: a module hook is now able
>>> to specify additional data files that are needed for the module to work
>>> correctly. Those data files are automatically collected when using

[cut]

>>
>> Hi Giovanni,
>> I'm trying the new pyinstaller-trunk on my PyQt based project.
>> The new hoks seems to fail collecting Qt4 plugins because
>>
>> hooks.hookutils.qt4_plugins_dir()
>>
>> returns
>>
>> "C:\Qt\4.4.1\plugins"
>>
>>
>> while the correct plugins location on my system is
>>
>> "C:\Python25\Lib\site-packages\PyQt4\plugins"
>>
>> I don't have Qt4 installed. I just used the standard PyQt4 installer
>> provided by riverback.
>> It seems to me a PyQt4 build issue and i can't figure out wich is the
>> best approach to solve this problem.
>>
>> Do you have any idea?
>
> It looks like PyQt's installer installs a qt.conf file specifying the
> plugin paths. Can you find a way to query that directory without having
> to parse qt.conf?

Giovanni,
I don't know how to perform that query. Maybe I could ask on the pyqt
mailing list.
Anyway qt.path is (on my PC) in

C:\Python25\Lib\site-packages\PyQt4

so I guess i could use something like

In [5]: PyQt4.__file__
Out[5]: 'C:\\Python25\\lib\\site-packages\\PyQt4\\__init__.pyc'

In [6]: PyQt4.__path__
Out[6]: ['C:\\Python25\\lib\\site-packages\\PyQt4']

to build the path.
I don't know if that is the standard place where qt.conf is put.

The content of the file is

[Paths]
Prefix = C:/Python25/Lib/site-packages/PyQt4
Binaries = .

so it shouldn't be a problem to parse it.
Why do you prefer avoid parsing?

ciao

--
Antonio VALENTINO

Giovanni Bajo

unread,
Feb 27, 2009, 1:01:45 PM2/27/09
to PyIns...@googlegroups.com

Because the point is that I should ask Qt (through PyQt) where the
plugins are; otherwise, PyInstaller's hooks would have to reproduce all
the logic that Qt does to discover possible plugin paths (which are
arbitrarly complex, vary arbitrarly through versions, etc.). I don't
want to duplicate all that code: there must be a way to ask Qt where it
is looking for plugins.

I'll investigate further.

Antonio Valentino

unread,
Feb 27, 2009, 1:59:14 PM2/27/09
to PyIns...@googlegroups.com
Il giorno Fri, 27 Feb 2009 19:01:45 +0100
Giovanni Bajo <ra...@develer.com> ha scritto:

Giovanni,
if my understanding of

http://doc.trolltech.com/4.4/qt-conf.html

is correct the "way to ask Qt where it is looking for plugins" exists
and it is exactly the one you used in hookutils.
The problem is, IMHO, that something is broken somewhere so the best we
can do is detect the failure and try some sort of workaroud.

> I'll investigate further.


--
Antonio Valentino

Reply all
Reply to author
Forward
0 new messages