[PyQt] QSettings with normal and "bundled" apps

Colin McPhail colin.mcphail at mac.com
Tue Jan 27 16:56:09 GMT 2015


> On 27 Jan 2015, at 15:37, David Cortesi <davecortesi at gmail.com> wrote:
> 
> The following relates to Python3.4, PyQt5.4, and OS X 10.10.
> 
> While trying to bundle an app for distribution I found that
> the behavior of QSettings differs between the app when run by
> CPython from the command line, and when it runs in a “bundle”
> as prepared by cx_freeze[1] OR by PyInstaller[2].
> 
> The apps made by either bundling method fail in the
> identical way. That is why I am bringing this to the PyQt
> list first. I have reduced it to a bare minimum of code
> in hopes someone can suggest what to investigate next.
> 
> [14:04:48 scratch] cat writer.py
> from PyQt5.QtCore import QCoreApplication, QSettings
> app = QCoreApplication([])
> app.setOrganizationName("BOGUS_NAME")
> app.setOrganizationDomain("bogosity.com")
> app.setApplicationName("BOGUS_APP")
> settings = QSettings()
> settings.clear()
> settings.setValue('b',b'\xde\xad\xbe\xef’)

In the unbundled case, wrapping the settings value as a QBytesArray:
    settings.setValue('b’,QBytesArray(b'\xde\xad\xbe\xef’))
results in a simpler-looking plist file:
$ hexdump -C ~/Library/Preferences/com.bogosity.BOGUS_APP.plist
00000000  62 70 6c 69 73 74 30 30  d1 01 02 51 62 44 de ad  |bplist00...QbD..|
00000010  be ef 08 0b 0d 00 00 00  00 00 00 01 01 00 00 00  |................|
00000020  00 00 00 00 03 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 12                                    |.....|
00000035
$ 

Does that help the bundled versions?
Regards,
— CMcP



More information about the PyQt mailing list