def run(self): py2app.run(self) # XXX py2app can't copy Qt plugins. plugins = os.path.join(unicode(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.PluginsPath)), "imageformats") dest = os.path.abspath("dist/MusicBrainz Picard.app/Contents/plugins/imageformats") self.mkpath(dest) for lib in ("libqgif.dylib", "libqjpeg.dylib", "libqtiff.dylib"): src_file = os.path.join(plugins, lib) if os.path.isfile(src_file): dest_file = os.path.join(dest, lib) copy_file(src_file, dest_file) call(["install_name_tool", "-change", "QtCore.framework/Versions/4/QtCore", "@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore", dest_file]) call(["install_name_tool", "-change", "QtGui.framework/Versions/4/QtGui", "@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui", dest_file]) # XXX Without qt.conf, launching the app bundle results in a ton of warnings about # "loading two sets of Qt binaries into the same process," followed by it crashing. # Tools like macdeployqt create this file automatically, with the same contents. fp = open("dist/MusicBrainz Picard.app/Contents/Resources/qt.conf", "w") fp.writelines(["[Paths]", "Prefix="]) fp.close() # XXX Find and bundle fpcalc, since py2app can't. fpcalc = find_app("fpcalc") if fpcalc: dest_fpcalc = os.path.abspath("dist/MusicBrainz Picard.app/Contents/MacOS/fpcalc") copy_file(fpcalc, dest_fpcalc) os.chmod(dest_fpcalc, 0755)
def run(self): py2app.run(self) # XXX Find and bundle fpcalc, since py2app can't. fpcalc = find_app("fpcalc") if fpcalc: dest_fpcalc = os.path.abspath("dist/MusicBrainz Picard.app/Contents/MacOS/fpcalc") copy_file(fpcalc, dest_fpcalc) os.chmod(dest_fpcalc, 0o755)
def run(self): py2app.run(self) # XXX py2app can't copy Qt plugins. plugins = os.path.join( unicode( QtCore.QLibraryInfo.location( QtCore.QLibraryInfo.PluginsPath)), "imageformats") dest = os.path.abspath( "dist/MusicBrainz Picard.app/Contents/plugins/imageformats") self.mkpath(dest) for lib in ("libqgif.dylib", "libqjpeg.dylib", "libqtiff.dylib"): src_file = os.path.join(plugins, lib) if os.path.isfile(src_file): dest_file = os.path.join(dest, lib) copy_file(src_file, dest_file) call([ "install_name_tool", "-change", "QtCore.framework/Versions/4/QtCore", "@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore", dest_file ]) call([ "install_name_tool", "-change", "QtGui.framework/Versions/4/QtGui", "@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui", dest_file ]) # XXX Without qt.conf, launching the app bundle results in a ton of warnings about # "loading two sets of Qt binaries into the same process," followed by it crashing. # Tools like macdeployqt create this file automatically, with the same contents. fp = open("dist/MusicBrainz Picard.app/Contents/Resources/qt.conf", "w") fp.writelines(["[Paths]", "Prefix="]) fp.close() # XXX Find and bundle fpcalc, since py2app can't. fpcalc = find_app("fpcalc") if fpcalc: dest_fpcalc = os.path.abspath( "dist/MusicBrainz Picard.app/Contents/MacOS/fpcalc") copy_file(fpcalc, dest_fpcalc) os.chmod(dest_fpcalc, 0755)
def copy_package_data(self, package, target_dir): """ Copy any package data in a python package into the target_dir. This is a bit of a hack, it would be better to identify python eggs and copy those in whole. """ exts = [i[0] for i in imp.get_suffixes()] exts.append('.py') exts.append('.pyc') exts.append('.pyo') def datafilter(item): for e in exts: if item.endswith(e): return False return True target_dir = os.path.join(target_dir, *(package.identifier.split('.'))) for dname in package.packagepath: filenames = filter(datafilter, os_listdir(dname)) for fname in filenames: if fname in ('.svn', 'CVS'): # Scrub revision manager junk continue pth = os.path.join(dname, fname) # Check if we have found a package, exclude those if os_path_isdir(pth): for p in os_listdir(pth): if p.startswith('__init__.') and p[8:] in exts: break else: copy_tree(pth, os.path.join(target_dir, fname)) continue else: copy_file(pth, os.path.join(target_dir, fname))
def copy_package_data(self, package, target_dir): """ Copy any package data in a python package into the target_dir. This is a bit of a hack, it would be better to identify python eggs and copy those in whole. """ exts = [ i[0] for i in imp.get_suffixes() ] exts.append('.py') exts.append('.pyc') exts.append('.pyo') def datafilter(item): for e in exts: if item.endswith(e): return False return True target_dir = os.path.join(target_dir, *(package.identifier.split('.'))) for dname in package.packagepath: filenames = filter(datafilter, os_listdir(dname)) for fname in filenames: if fname in ('.svn', 'CVS'): # Scrub revision manager junk continue pth = os.path.join(dname, fname) # Check if we have found a package, exclude those if os_path_isdir(pth): for p in os_listdir(pth): if p.startswith('__init__.') and p[8:] in exts: break else: copy_tree(pth, os.path.join(target_dir, fname)) continue else: copy_file(pth, os.path.join(target_dir, fname))
def build_executable(self, target, arcname, pkgexts, copyexts, script): # Build an executable for the target appdir, resdir, plist = self.create_bundle(target, script) self.appdir = appdir self.resdir = resdir self.plist = plist for src, dest in self.iter_data_files(): dest = os.path.join(resdir, dest) self.mkpath(os.path.dirname(dest)) copy_resource(src, dest, dry_run=self.dry_run) self.compile_datamodels(resdir) self.compile_mappingmodels(resdir) bootfn = '__boot__' bootfile = file(os.path.join(resdir, bootfn + '.py'), 'w') for fn in target.prescripts: bootfile.write(self.get_bootstrap_data(fn)) bootfile.write('\n\n') bootfile.write('_run(%r)\n' % (os.path.basename(script),)) bootfile.close() self.copy_file(script, resdir) pydir = os.path.join(resdir, 'lib', 'python' + sys.version[:3]) realhome = os.path.join(sys.prefix, 'lib', 'python' + sys.version[:3]) self.mkpath(pydir) self.symlink('../../site.py', os.path.join(pydir, 'site.py')) cfgdir = os.path.join(pydir, 'config') realcfg = os.path.join(realhome, 'config') real_include = os.path.join(sys.prefix, 'include') if self.semi_standalone: self.symlink(realcfg, cfgdir) self.symlink(real_include, os.path.join(resdir, 'include')) else: self.mkpath(cfgdir) for fn in 'Makefile', 'Setup', 'Setup.local', 'Setup.config': rfn = os.path.join(realcfg, fn) if os.path.exists(rfn): self.copy_file(rfn, os.path.join(cfgdir, fn)) inc_dir = os.path.join(resdir, 'include', 'python' + sys.version[:3]) self.mkpath(inc_dir) self.copy_file(os.path.join(real_include, 'python%s/pyconfig.h'%( sys.version[:3])), os.path.join(inc_dir, 'pyconfig.h')) self.copy_file(arcname, pydir) ext_dir = os.path.join(pydir, os.path.basename(self.ext_dir)) self.copy_tree(self.ext_dir, ext_dir, preserve_symlinks=True) self.copy_tree(self.framework_dir, os.path.join(appdir, 'Contents', 'Frameworks'), preserve_symlinks=True) for pkg in self.packages: pkg = self.get_bootstrap(pkg) dst = os.path.join(pydir, os.path.basename(pkg)) self.mkpath(dst) self.copy_tree(pkg, dst) for copyext in copyexts: fn = os.path.join(ext_dir, (copyext.identifier.replace('.', os.sep) + os.path.splitext(copyext.filename)[1]) ) self.mkpath(os.path.dirname(fn)) copy_file(copyext.filename, fn, dry_run=self.dry_run) target.appdir = appdir return appdir
scriptFolder = os.path.abspath(os.path.dirname(inspect.getfile(inspect.currentframe()))) makeExecutable(os.path.join(scriptFolder, "dist_mac/StoryTime.app/Contents/Resources/bin/mac/ffmpeg")) makeExecutable(os.path.join(scriptFolder, "dist_mac/StoryTime.app/Contents/Resources/bin/linux/ffmpeg")) # Copy the qt plugins so we can use jpegs # if os.path.isdir('dist_mac/StoryTime.app/Contents/plugins'): # shutil.rmtree('dist_mac/StoryTime.app/Contents/plugins') # shutil.copytree(os.path.abspath('storyTime/bin/mac/plugins'), 'dist_mac/StoryTime.app/Contents/plugins') appPath = "dist_mac/StoryTime.app/Contents" plugins = os.path.join(unicode(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.PluginsPath)), "imageformats") qtLibPath = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.LibrariesPath) print "qtLibPath: {0}".format(qtLibPath) # TESTING dest = os.path.abspath("dist_mac/StoryTime.app/Contents/Resources/qt_plugins/imageformats") os.makedirs(dest) for lib in ("libqgif.dylib", "libqjpeg.dylib", "libqtiff.dylib"): src_file = os.path.join(plugins, lib) if os.path.isfile(src_file): print "dest_file: {0}".format(dest) # TESTING print "lib: {0}".format(lib) # TESTING print "src_file: {0}".format(src_file) # TESTING dest_file = os.path.join(dest, lib) print "dest_file: {0}".format(dest_file) # TESTING copy_file(src_file, dest_file) srcQtCore = os.path.join(qtLibPath, "QtCore.framework/Versions/4/QtCore") srcQtGui = os.path.join(qtLibPath, "QtGui.framework/Versions/4/QtGui") call(["install_name_tool", "-change", srcQtCore, "@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore", dest_file]) call(["install_name_tool", "-change", srcQtGui, "@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui", dest_file])
def build_executable(self, target, arcname, pkgexts, copyexts, script): # Build an executable for the target appdir, resdir, plist = self.create_bundle(target, script) self.appdir = appdir self.resdir = resdir self.plist = plist for src, dest in self.iter_data_files(): dest = os.path.join(resdir, dest) self.mkpath(os.path.dirname(dest)) copy_resource(src, dest, dry_run=self.dry_run) self.compile_datamodels(resdir) self.compile_mappingmodels(resdir) bootfn = '__boot__' bootfile = file(os.path.join(resdir, bootfn + '.py'), 'w') for fn in target.prescripts: bootfile.write(self.get_bootstrap_data(fn)) bootfile.write('\n\n') bootfile.write('_run(%r)\n' % (os.path.basename(script), )) bootfile.close() self.copy_file(script, resdir) pydir = os.path.join(resdir, 'lib', 'python' + sys.version[:3]) realhome = os.path.join(sys.prefix, 'lib', 'python' + sys.version[:3]) self.mkpath(pydir) self.symlink('../../site.py', os.path.join(pydir, 'site.py')) cfgdir = os.path.join(pydir, 'config') realcfg = os.path.join(realhome, 'config') real_include = os.path.join(sys.prefix, 'include') if self.semi_standalone: self.symlink(realcfg, cfgdir) self.symlink(real_include, os.path.join(resdir, 'include')) else: self.mkpath(cfgdir) for fn in 'Makefile', 'Setup', 'Setup.local', 'Setup.config': rfn = os.path.join(realcfg, fn) if os.path.exists(rfn): self.copy_file(rfn, os.path.join(cfgdir, fn)) inc_dir = os.path.join(resdir, 'include', 'python' + sys.version[:3]) self.mkpath(inc_dir) self.copy_file( os.path.join(real_include, 'python%s/pyconfig.h' % (sys.version[:3])), os.path.join(inc_dir, 'pyconfig.h')) self.copy_file(arcname, pydir) ext_dir = os.path.join(pydir, os.path.basename(self.ext_dir)) self.copy_tree(self.ext_dir, ext_dir, preserve_symlinks=True) self.copy_tree(self.framework_dir, os.path.join(appdir, 'Contents', 'Frameworks'), preserve_symlinks=True) for pkg in self.packages: pkg = self.get_bootstrap(pkg) dst = os.path.join(pydir, os.path.basename(pkg)) self.mkpath(dst) self.copy_tree(pkg, dst) for copyext in copyexts: fn = os.path.join(ext_dir, (copyext.identifier.replace('.', os.sep) + os.path.splitext(copyext.filename)[1])) self.mkpath(os.path.dirname(fn)) copy_file(copyext.filename, fn, dry_run=self.dry_run) target.appdir = appdir return appdir