diff --git a/bypy/macos/__main__.py b/bypy/macos/__main__.py index d8b012cc12..dc94d8e714 100644 --- a/bypy/macos/__main__.py +++ b/bypy/macos/__main__.py @@ -33,7 +33,7 @@ QT_DLLS, QT_PLUGINS, PYQT_MODULES = iv['QT_DLLS'], iv['QT_PLUGINS'], iv['PYQT_MO py_ver = '.'.join(map(str, python_major_minor_version())) sign_app = runpy.run_path(join(dirname(abspath(__file__)), 'sign.py'))['sign_app'] -QT_PREFIX = os.path.join(PREFIX, 'qt') +QT_PREFIX = join(PREFIX, 'qt') QT_FRAMEWORKS = [x.replace('5', '') for x in QT_DLLS] ENV = dict( @@ -159,14 +159,17 @@ class Freeze(object): FID = '@executable_path/../Frameworks' def __init__(self, build_dir, ext_dir, test_runner, test_launchers=False, dont_strip=False, sign_installers=False): - self.build_dir = build_dir + self.build_dir = os.path.realpath(build_dir) self.sign_installers = sign_installers - self.ext_dir = ext_dir + self.ext_dir = os.path.realpath(ext_dir) self.test_runner = test_runner self.dont_strip = dont_strip self.contents_dir = join(self.build_dir, 'Contents') self.resources_dir = join(self.contents_dir, 'Resources') self.frameworks_dir = join(self.contents_dir, 'Frameworks') + self.exe_dir = join(self.contents_dir, 'MacOS') + self.helpers_dir = join(self.build_dir, 'Helpers', 'utils.app', 'Contents', 'MacOS') + self.webengine_dir = join(self.build_dir, 'Helpers', 'QtWebEngineProcess.app', 'Contents', 'MacOS') self.site_packages = join(self.resources_dir, 'Python', 'site-packages') self.to_strip = [] self.warnings = [] @@ -211,12 +214,12 @@ class Freeze(object): @flush def run_tests(self): - cc_dir = os.path.join(self.contents_dir, 'calibre-debug.app', 'Contents') + cc_dir = join(self.contents_dir, 'calibre-debug.app', 'Contents') self.test_runner(join(cc_dir, 'MacOS', 'calibre-debug'), self.contents_dir) @flush def add_resources(self): - shutil.copytree('resources', os.path.join(self.resources_dir, + shutil.copytree('resources', join(self.resources_dir, 'resources')) @flush @@ -262,6 +265,8 @@ class Freeze(object): yield x, x[len('@rpath/'):], is_id elif x.startswith('@rpath/libjpeg'): yield x, x[len('@rpath/'):], is_id + elif x.startswith('@rpath/libpoppler'): + yield x, x[len('@rpath/'):], is_id else: for y in (PREFIX + '/lib/', PREFIX + '/python/Python.framework/'): if x.startswith(y): @@ -356,6 +361,12 @@ class Freeze(object): subprocess.check_call([ 'iconutil', '-c', 'icns', x, '-o', join( self.resources_dir, basename(x).partition('.')[0] + '.icns')]) + for helpers in (self.helpers_dir, self.webengine_dir): + os.makedirs(helpers) + cdir = dirname(helpers) + dest = join(cdir, 'Frameworks') + src = self.frameworks_dir + os.symlink(os.path.relpath(src, cdir), dest) @flush def add_calibre_plugins(self): @@ -408,12 +419,14 @@ class Freeze(object): plistlib.dump(pl, p) @flush - def install_dylib(self, path, set_id=True): - shutil.copy2(path, self.frameworks_dir) + def install_dylib(self, path, set_id=True, dest=None): + dest = dest or self.frameworks_dir + os.makedirs(dest, exist_ok=True) + shutil.copy2(path, dest) if set_id: - self.set_id(join(self.frameworks_dir, basename(path)), + self.set_id(join(dest, basename(path)), self.FID + '/' + basename(path)) - self.fix_dependencies_in_lib(join(self.frameworks_dir, basename(path))) + self.fix_dependencies_in_lib(join(dest, basename(path))) @flush def add_podofo(self): @@ -425,32 +438,34 @@ class Freeze(object): def add_poppler(self): print('\nAdding poppler') for x in ('libpoppler.87.dylib',): - self.install_dylib(os.path.join(PREFIX, 'lib', x)) + self.install_dylib(join(PREFIX, 'lib', x)) for x in ('pdftohtml', 'pdftoppm', 'pdfinfo'): - self.install_dylib(os.path.join(PREFIX, 'bin', x), False) + self.install_dylib( + join(PREFIX, 'bin', x), set_id=False, dest=self.helpers_dir) @flush def add_imaging_libs(self): print('\nAdding libjpeg, libpng, libwebp, optipng and mozjpeg') for x in ('jpeg.8', 'png16.16', 'webp.7', 'webpmux.3', 'webpdemux.2'): - self.install_dylib(os.path.join(PREFIX, 'lib', 'lib%s.dylib' % x)) + self.install_dylib(join(PREFIX, 'lib', 'lib%s.dylib' % x)) for x in 'optipng', 'JxrDecApp': - self.install_dylib(os.path.join(PREFIX, 'bin', x), False) + self.install_dylib(join(PREFIX, 'bin', x), set_id=False, dest=self.helpers_dir) for x in ('jpegtran', 'cjpeg'): - self.install_dylib(os.path.join(PREFIX, 'private', 'mozjpeg', 'bin', x), False) + self.install_dylib( + join(PREFIX, 'private', 'mozjpeg', 'bin', x), set_id=False, dest=self.helpers_dir) @flush def add_fontconfig(self): print('\nAdding fontconfig') for x in ('fontconfig.1', 'freetype.6', 'expat.1'): - src = os.path.join(PREFIX, 'lib', 'lib' + x + '.dylib') + src = join(PREFIX, 'lib', 'lib' + x + '.dylib') self.install_dylib(src) - dst = os.path.join(self.resources_dir, 'fonts') + dst = join(self.resources_dir, 'fonts') if os.path.exists(dst): shutil.rmtree(dst) - src = os.path.join(PREFIX, 'etc', 'fonts') + src = join(PREFIX, 'etc', 'fonts') shutil.copytree(src, dst, symlinks=False) - fc = os.path.join(dst, 'fonts.conf') + fc = join(dst, 'fonts.conf') with open(fc, 'rb') as f: raw = f.read().decode('utf-8') raw = raw.replace('