mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
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:
parent
8e125b56a0
commit
8aceae428e
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user