py3: make setup.py gui work

Apparently compileUi explicitly opens the file/buffer as unicode, not
bytes, and then writes a unicode header string (containing the source
file). So the previous attempt to use BytesIO was wrong in this case.

Also images.qrc is being constructed completely in the right here and
now from a bunch of unicode strings, so just use exactly that.
This commit is contained in:
Eli Schwartz 2019-03-20 23:50:46 -04:00
parent 8e125b56a0
commit 8aceae428e
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
2 changed files with 3 additions and 3 deletions

View File

@ -58,7 +58,7 @@ class GUI(Command):
for s in sources:
files.append('<file>%s</file>'%s)
manifest = '<RCC>\n<qresource prefix="/">\n%s\n</qresource>\n</RCC>'%'\n'.join(sorted(files))
with open('images.qrc', 'wb') as f:
with open('images.qrc', 'w') as f:
f.write(manifest)
finally:
os.chdir(cwd)

View File

@ -1288,7 +1288,7 @@ def build_forms(srcdir, info=None, summary=False, check_for_migration=False):
if force_compile or not os.path.exists(compiled_form) or os.stat(form).st_mtime > os.stat(compiled_form).st_mtime:
if not summary:
info('\tCompiling form', form)
buf = io.BytesIO()
buf = io.StringIO()
compileUi(form, buf)
dat = buf.getvalue()
dat = dat.replace('import images_rc', '')
@ -1298,7 +1298,7 @@ def build_forms(srcdir, info=None, summary=False, check_for_migration=False):
dat = dat.replace('_("d MMM yyyy")', '"d MMM yyyy"')
dat = pat.sub(sub, dat)
open(compiled_form, 'wb').write(dat)
open(compiled_form, 'w').write(dat)
num += 1
if num:
info('Compiled %d forms' % num)