def run(self):
     py2app_cmd.run(self)
     self.setup_directories()
     self.copy_ffmpeg()
     self.copy_sparkle()
     self.copy_update_public_key()
     self.delete_site_py()
示例#2
0
 def run(self):
     py2app_cmd.run(self)
     self.setup_directories()
     self.copy_ffmpeg()
     self.copy_sparkle()
     self.copy_update_public_key()
     self.delete_site_py()
示例#3
0
        def run(self):
            build_py2app.run(self)
            if self.dry_run:
                return

            # undo py2app's weird treatment of the config.version value
            info_pth = 'dist/PlotDevice.app/Contents/Info.plist'
            update_plist(info_pth, CFBundleShortVersionString=None)

            # set up internal paths and ensure destination dirs exist
            RSRC = self.resdir
            BIN = join(dirname(RSRC), 'SharedSupport')
            LIB = join(RSRC, 'python')
            MODULES = join(self.bdist_base, 'lib')

            # install the module in Resources/python
            self.spawn(['/usr/bin/ditto', MODULES, LIB])

            # discard the eggery-pokery
            remove_tree(join(RSRC,'lib'), dry_run=self.dry_run)
            os.unlink(join(RSRC,'include'))
            os.unlink(join(RSRC,'site.pyc'))

            # place the command line tool in SharedSupport
            self.mkpath(BIN)
            self.copy_file("app/plotdevice", BIN)

            # success!
            print("done building PlotDevice.app in ./dist")
示例#4
0
文件: setup.py 项目: alteveer/picard
        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)
示例#5
0
    def run(self):
        """Runs original py2app and deletes all files containing
        'debug' in their name.
        """
        # First normal py2app run
        _py2app.run(self)
        # Then remove debuging files
        print '*** removing Qt debug and unneeded  libs ***'
        for root, dirs, files in os.walk(self.dist_dir):
            for file in files:
                if 'debug' in file :
                    print 'removing', file
                    os.remove(os.path.join(root,file))

        if self.no_plugins is False:
           print "Copy plugins..."
           os.system("sh copy-plugins.sh")

           print "Generate qt.conf file..."
           ofi = open("dist/" + NAME + ".app/Contents/Resources/qt.conf", "w")
           print >> ofi, "[Paths]"
           print >> ofi, "Plugins = plugins"
           print >> ofi
           ofi.close()

        if self.no_mpkg is False:
           print "Generate mpkg..."
           pkgmgr_cmd = PKGMGR + " --doc series60-remote.pmdoc -o ./" + NAME + ".mpkg -v"
           os.system(pkgmgr_cmd)

           if self.no_dmg is False:
              print "Generate dmg"
              DIR = "build-dmg-%i" % random.Random().randint(1, 10000)
              copy_tree(NAME + ".mpkg", DIR + os.sep + NAME + ".mpkg", preserve_symlinks=1)
              os.system("perl pkg-dmg.pl --source %s --target %s --volname '%s' --icon phone.icns" % (DIR, NAME + "_" + VERSION + ".dmg", NAME + " " + VERSION))
示例#6
0
        def run(self):
            assert os.getcwd(
            ) == self.cwd, 'Must be in package root: %s' % self.cwd
            build_py2app.run(self)
            if self.dry_run:
                return

            # undo py2app's weird treatment of the config.version value
            info_pth = 'dist/PlotDevice.app/Contents/Info.plist'
            update_plist(info_pth, CFBundleShortVersionString=None)

            # set up internal paths and ensure destination dirs exist
            RSRC = self.resdir
            BIN = join(dirname(RSRC), 'SharedSupport')
            MODULE = join(self.bdist_base, 'lib/plotdevice')
            PY = join(RSRC, 'python')
            for pth in BIN, PY:
                self.mkpath(pth)

            # install the module in Resources/python
            self.spawn(['/usr/bin/ditto', MODULE, join(PY, 'plotdevice')])

            # discard the eggery-pokery
            remove_tree(join(RSRC, 'lib'), dry_run=self.dry_run)
            os.unlink(join(RSRC, 'include'))
            os.unlink(join(RSRC, 'site.pyc'))

            # place the command line tool in SharedSupport
            self.copy_file("app/plotdevice", BIN)

            # success!
            print "done building PlotDevice.app in ./dist"
示例#7
0
文件: setup.py 项目: mytardis/mydata
 def run(self):
     py2app.run(self)
     shutil.copy("resources/macosx/MyData Notifications.app/Contents/MacOS"
                 "/MyData Notifications", "dist/MyData.app/Contents/MacOS/")
     distutils.dir_util\
         .copy_tree("resources/macosx/MyData Notifications.app/Contents"
                    "/Resources/en.lproj",
                    "dist/MyData.app/Contents/Resources/en.lproj")
示例#8
0
 def run (self):
     """Generate py2app installer."""
     # First, let py2app do it's work.
     py2app_build.run(self)
     # Fix install names for Qt plugin libraries.
     fix_qt_plugins_py2app(self.dist_dir)
     sign_the_code(self.dist_dir)
     generate_dmg_image(self.dist_dir)
示例#9
0
 def run(self):
     """Generate py2app installer."""
     # First, let py2app do it's work.
     py2app_build.run(self)
     # Fix install names for Qt plugin libraries.
     fix_qt_plugins_py2app(self.dist_dir)
     sign_the_code(self.dist_dir)
     generate_dmg_image(self.dist_dir)
示例#10
0
文件: setup.py 项目: queer1/picard
        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)
示例#11
0
        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)
示例#12
0
 def run(self):
     py2app_cmd.run(self)
     bundle_root = os.path.join(self.dist_dir, "Miro Video Converter.app/Contents")
     helpers_root = os.path.join(bundle_root, "Helpers")
     if os.path.exists(helpers_root):
         shutil.rmtree(helpers_root)
     print "Copying FFmpeg to", helpers_root
     os.mkdir(helpers_root)
     ffmpeg_files = ["ffmpeg"]
     lib_paths = glob.glob(os.path.join(BKIT_DIR, "ffmpeg", "bin", "*.dylib"))
     ffmpeg_files.extend(os.path.basename(p) for p in lib_paths)
     copy_binaries("ffmpeg/bin/", helpers_root, ffmpeg_files)
示例#13
0
 def run(self):
     py2app_cmd.run(self)
     bundle_root = os.path.join(self.dist_dir,
                                'Miro Video Converter.app/Contents')
     helpers_root = os.path.join(bundle_root, 'Helpers')
     if os.path.exists(helpers_root):
         shutil.rmtree(helpers_root)
     print 'Copying FFmpeg to', helpers_root
     os.mkdir(helpers_root)
     ffmpeg_files = ["ffmpeg"]
     lib_paths = glob.glob(
         os.path.join(BKIT_DIR, "ffmpeg", "bin", "*.dylib"))
     ffmpeg_files.extend(os.path.basename(p) for p in lib_paths)
     copy_binaries('ffmpeg/bin/', helpers_root, ffmpeg_files)
示例#14
0
  def run(self):
    py2app.run(self)
    print ">>>>> installing ffmpeg2theora <<<<<<"
    resourcesRoot = os.path.join(self.dist_dir, 'Simple Theora Encoder.app/Contents/Resources')
    shutil.copy('ffmpeg2theora', os.path.join(resourcesRoot, 'ffmpeg2theora'))
    #rsrc_file = "Simple Theora Encoder.rsrc.py"
    #shutil.copy(rsrc_file, os.path.join(resourcesRoot, rsrc_file))

    imgPath = os.path.join(self.dist_dir, "Simple Theora Encoder.dmg")
    os.system('''hdiutil create -srcfolder "%s" -volname "Simple Theora Encoder" -format UDZO "%s"''' %
                (self.dist_dir, os.path.join(self.dist_dir, "Simple Theora Encoder.tmp.dmg")))
    os.system('''hdiutil convert -format UDZO -imagekey zlib-level=9 -o "%s" "%s"''' %
                (imgPath, os.path.join(self.dist_dir, "Simple Theora Encoder.tmp.dmg")))
    os.remove(os.path.join(self.dist_dir,"Simple Theora Encoder.tmp.dmg"))
示例#15
0
文件: setup.py 项目: weisslj/picard
        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)
示例#16
0
    def run(self):
        """Runs original py2app and deletes all files containing
        'debug' in their name.
        """
        # First normal py2app run
        _py2app.run(self)
        # Then remove debuging files
        print '*** removing Qt debug and unneeded  libs ***'
        for root, dirs, files in os.walk(self.dist_dir):
            for file in files:
                if 'debug' in file:
                    print 'removing', file
                    os.remove(os.path.join(root, file))

        if self.no_plugins is False:
            print "Copy plugins..."
            os.system("sh copy-plugins.sh")

            print "Generate qt.conf file..."
            ofi = open("dist/" + NAME + ".app/Contents/Resources/qt.conf", "w")
            print >> ofi, "[Paths]"
            print >> ofi, "Plugins = plugins"
            print >> ofi
            ofi.close()

        if self.no_mpkg is False:
            print "Generate mpkg..."
            pkgmgr_cmd = PKGMGR + " --doc series60-remote.pmdoc -o ./" + NAME + ".mpkg -v"
            os.system(pkgmgr_cmd)

            if self.no_dmg is False:
                print "Generate dmg"
                DIR = "build-dmg-%i" % random.Random().randint(1, 10000)
                copy_tree(NAME + ".mpkg",
                          DIR + os.sep + NAME + ".mpkg",
                          preserve_symlinks=1)
                os.system(
                    "perl pkg-dmg.pl --source %s --target %s --volname '%s' --icon phone.icns"
                    %
                    (DIR, NAME + "_" + VERSION + ".dmg", NAME + " " + VERSION))
示例#17
0
    def run(self):

        orig_py2app.run(self)

        version = get_fsleyes_version()
        copyright = get_fsleyes_copyright()

        distdir = op.join(basedir, 'dist')
        contentsdir = op.join(distdir, 'FSLeyes.app', 'Contents')
        plist = op.join(contentsdir, 'Info.plist')
        resourcedir = op.join(contentsdir, 'Resources')

        # py2app (and pyinstaller) seem to
        # get the wrong version of libpng,
        # which causes render to segfault
        pildir = package_path('PIL')
        dylib = op.join(pildir, 'PIL', '.dylibs', 'libpng16.16.dylib')
        if op.exists(dylib):
            shutil.copy(dylib, op.join(contentsdir, 'Frameworks'))

        # copy the application document iconset
        shutil.copy(self.dociconfile, resourcedir)

        # Patch Info.plist
        commands = [
            ['delete', 'PythonInfoDict'],
            ['write', 'CFBundleShortVersionString', version],
            ['write', 'CFBundleVersion', version],
            ['write', 'NSHumanReadableCopyright', copyright],
        ]

        for c in commands:
            sp.call(['defaults'] + [c[0]] + [plist] + c[1:])

        # The defaults command screws with Info.plist
        # so make sure it has rw-r--r-- permissions
        sp.call(['chmod', '644', plist])
示例#18
0
 def run(self):
     py2app.run(self)
示例#19
0
    def run(self):
        py2app.run(self)
        resource_dir = os.path.join(self.dist_dir, APPNAME + '.app',
                                    'Contents', 'Resources')
        frameworks_dir = os.path.join(os.path.dirname(resource_dir),
                                      'Frameworks')
        all_scripts = scripts['console'] + scripts['gui']
        all_names = basenames['console'] + basenames['gui']
        all_modules = main_modules['console'] + main_modules['gui']
        all_functions = main_functions['console'] + main_functions['gui']

        info('\nAdding resources')
        dest = os.path.join(resource_dir, 'resources')
        if os.path.exists(dest):
            shutil.rmtree(dest)
        shutil.copytree(os.path.join(os.path.dirname(SRC), 'resources'), dest)

        info('\nAdding PoDoFo')
        pdf = glob.glob(
            os.path.expanduser('/Volumes/sw/podofo/libpodofo*.dylib'))[0]
        shutil.copyfile(pdf, os.path.join(frameworks_dir,
                                          os.path.basename(pdf)))

        info('\nAdding poppler')
        popps = []
        for x in ('bin/pdftohtml', 'lib/libpoppler.5.dylib'):
            dest = os.path.join(frameworks_dir, os.path.basename(x))
            popps.append(dest)
            shutil.copy2(os.path.join('/Volumes/sw', x), dest)
        subprocess.check_call([
            'install_name_tool', '-change',
            '/usr/local/lib/libfontconfig.1.dylib',
            '@executable_path/../Frameworks/libfontconfig.1.dylib',
            os.path.join(frameworks_dir, 'pdftohtml')
        ])
        x = 'libpng12.0.dylib'
        shutil.copy2('/usr/local/lib/' + x, frameworks_dir)
        subprocess.check_call([
            'install_name_tool', '-id', '@executable_path/../Frameworks/' + x,
            os.path.join(frameworks_dir, x)
        ])
        self.fix_misc_dependencies(popps)
        subprocess.check_call([
            'install_name_tool', '-change',
            '/usr/local/lib/libfontconfig.1.dylib',
            '@executable_path/../Frameworks/libfontconfig.1.dylib', popps[1]
        ])
        subprocess.check_call([
            'install_name_tool', '-id',
            '@executable_path/../Frameworks/' + os.path.basename(popps[1]),
            popps[1]
        ])

        loader_path = os.path.join(resource_dir, 'loaders')
        if not os.path.exists(loader_path):
            os.mkdir(loader_path)
        for name, module, function in zip(all_names, all_modules,
                                          all_functions):
            path = os.path.join(loader_path, name)
            info('Creating loader:', path)
            f = open(path, 'w')
            f.write(BuildAPP.LOADER_TEMPLATE %
                    dict(module=module, function=function))
            f.close()
            os.chmod(path, stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IREAD\
                     |stat.S_IWUSR|stat.S_IROTH|stat.S_IRGRP)

        info('Adding fontconfig')
        for f in glob.glob(os.path.expanduser('~/fontconfig-bundled/*')):
            dest = os.path.join(frameworks_dir, os.path.basename(f))
            if os.path.exists(dest):
                os.remove(dest)
            shutil.copyfile(f, dest)
        dst = os.path.join(resource_dir, 'fonts')
        if os.path.exists(dst):
            shutil.rmtree(dst)
        shutil.copytree('/usr/local/etc/fonts', dst, symlinks=False)

        self.add_plugins()

        info('Adding IPython')
        dst = os.path.join(resource_dir, 'lib', 'python2.6', 'IPython')
        if os.path.exists(dst): shutil.rmtree(dst)
        shutil.copytree(os.path.expanduser('~/build/ipython/IPython'), dst)

        info('Adding ImageMagick')
        libwmf = '/Volumes/sw/lib/libwmflite-0.2.7.dylib'
        dest = os.path.join(frameworks_dir, os.path.basename(libwmf))
        shutil.copy2(libwmf, frameworks_dir)
        nid = '@executable_path/../Frameworks/' + os.path.basename(dest)
        subprocess.check_call(['install_name_tool', '-id', nid, dest])
        dest = os.path.join(frameworks_dir, 'ImageMagick')
        if os.path.exists(dest):
            shutil.rmtree(dest)
        shutil.copytree(os.path.expanduser('~/ImageMagick'), dest, True)
        shutil.rmtree(os.path.join(dest, 'include'))
        shutil.rmtree(os.path.join(dest, 'share', 'doc'))
        shutil.rmtree(os.path.join(dest, 'share', 'man'))
        shutil.copyfile('/usr/local/lib/libpng12.0.dylib',
                        os.path.join(dest, 'lib', 'libpng12.0.dylib'))
        self.fix_image_magick_deps(dest)

        info('Installing prescipt')
        sf = [os.path.basename(s) for s in all_names]
        launcher_path = os.path.join(resource_dir, '__boot__.py')
        f = open(launcher_path, 'r')
        src = f.read()
        f.close()
        src = src.replace('import Image', 'from PIL import Image')
        src = re.sub(
            '(_run\s*\(.*?.py.*?\))', '%s' % ('''
sys.frameworks_dir = os.path.join(os.path.dirname(os.environ['RESOURCEPATH']), 'Frameworks')
sys.resources_location = os.path.join(os.environ['RESOURCEPATH'], 'resources')
sys.extensions_location = os.path.join(sys.frameworks_dir, 'plugins')
devf = os.environ.get('CALIBRE_DEVELOP_FROM', None)
do_devf = devf and os.path.exists(devf)
if do_devf:
    devf = os.path.abspath(devf)
    sys.path.insert(0, devf)
''') + r'\n\1', src)
        f = open(launcher_path, 'w')
        print >> f, 'import sys, os'
        f.write(src)
        f.close()

        info('\nAdding main scripts to site-packages')
        f = zipfile.ZipFile(
            os.path.join(self.dist_dir, APPNAME + '.app', 'Contents',
                         'Resources', 'lib', 'python' + sys.version[:3],
                         'site-packages.zip'), 'a', zipfile.ZIP_DEFLATED)
        for script in scripts['gui'] + scripts['console']:
            f.write(script, script.partition('/')[-1])
        f.close()

        info('\nCreating console.app')
        contents_dir = os.path.dirname(resource_dir)
        cc_dir = os.path.join(contents_dir, 'console.app', 'Contents')
        os.makedirs(cc_dir)
        for x in os.listdir(contents_dir):
            if x == 'console.app':
                continue
            if x == 'Info.plist':
                plist = plistlib.readPlist(os.path.join(contents_dir, x))
                plist['LSUIElement'] = '1'
                plistlib.writePlist(plist, os.path.join(cc_dir, x))
            else:
                os.symlink(os.path.join('../..', x), os.path.join(cc_dir, x))

        info('\nBuilding disk image')
        BuildAPP.makedmg(os.path.join(self.dist_dir, APPNAME + '.app'),
                         APPNAME + '-' + VERSION)
示例#20
0
    def run(self):
        py2app.run(self)
        resource_dir = os.path.join(self.dist_dir, APPNAME + ".app", "Contents", "Resources")
        frameworks_dir = os.path.join(os.path.dirname(resource_dir), "Frameworks")
        all_scripts = scripts["console"] + scripts["gui"]
        all_names = basenames["console"] + basenames["gui"]
        all_modules = main_modules["console"] + main_modules["gui"]
        all_functions = main_functions["console"] + main_functions["gui"]

        info("\nAdding resources")
        dest = os.path.join(resource_dir, "resources")
        if os.path.exists(dest):
            shutil.rmtree(dest)
        shutil.copytree(os.path.join(os.path.dirname(SRC), "resources"), dest)

        info("\nAdding PoDoFo")
        pdf = glob.glob(os.path.expanduser("/Volumes/sw/podofo/libpodofo*.dylib"))[0]
        shutil.copyfile(pdf, os.path.join(frameworks_dir, os.path.basename(pdf)))

        info("\nAdding poppler")
        popps = []
        for x in ("bin/pdftohtml", "lib/libpoppler.5.dylib"):
            dest = os.path.join(frameworks_dir, os.path.basename(x))
            popps.append(dest)
            shutil.copy2(os.path.join("/Volumes/sw", x), dest)
        subprocess.check_call(
            [
                "install_name_tool",
                "-change",
                "/usr/local/lib/libfontconfig.1.dylib",
                "@executable_path/../Frameworks/libfontconfig.1.dylib",
                os.path.join(frameworks_dir, "pdftohtml"),
            ]
        )
        x = "libpng12.0.dylib"
        shutil.copy2("/usr/local/lib/" + x, frameworks_dir)
        subprocess.check_call(
            ["install_name_tool", "-id", "@executable_path/../Frameworks/" + x, os.path.join(frameworks_dir, x)]
        )
        self.fix_misc_dependencies(popps)
        subprocess.check_call(
            [
                "install_name_tool",
                "-change",
                "/usr/local/lib/libfontconfig.1.dylib",
                "@executable_path/../Frameworks/libfontconfig.1.dylib",
                popps[1],
            ]
        )
        subprocess.check_call(
            ["install_name_tool", "-id", "@executable_path/../Frameworks/" + os.path.basename(popps[1]), popps[1]]
        )

        loader_path = os.path.join(resource_dir, "loaders")
        if not os.path.exists(loader_path):
            os.mkdir(loader_path)
        for name, module, function in zip(all_names, all_modules, all_functions):
            path = os.path.join(loader_path, name)
            info("Creating loader:", path)
            f = open(path, "w")
            f.write(BuildAPP.LOADER_TEMPLATE % dict(module=module, function=function))
            f.close()
            os.chmod(
                path,
                stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | stat.S_IREAD | stat.S_IWUSR | stat.S_IROTH | stat.S_IRGRP,
            )

        info("Adding fontconfig")
        for f in glob.glob(os.path.expanduser("~/fontconfig-bundled/*")):
            dest = os.path.join(frameworks_dir, os.path.basename(f))
            if os.path.exists(dest):
                os.remove(dest)
            shutil.copyfile(f, dest)
        dst = os.path.join(resource_dir, "fonts")
        if os.path.exists(dst):
            shutil.rmtree(dst)
        shutil.copytree("/usr/local/etc/fonts", dst, symlinks=False)

        self.add_plugins()

        info("Adding IPython")
        dst = os.path.join(resource_dir, "lib", "python2.6", "IPython")
        if os.path.exists(dst):
            shutil.rmtree(dst)
        shutil.copytree(os.path.expanduser("~/build/ipython/IPython"), dst)

        info("Adding ImageMagick")
        libwmf = "/Volumes/sw/lib/libwmflite-0.2.7.dylib"
        dest = os.path.join(frameworks_dir, os.path.basename(libwmf))
        shutil.copy2(libwmf, frameworks_dir)
        nid = "@executable_path/../Frameworks/" + os.path.basename(dest)
        subprocess.check_call(["install_name_tool", "-id", nid, dest])
        dest = os.path.join(frameworks_dir, "ImageMagick")
        if os.path.exists(dest):
            shutil.rmtree(dest)
        shutil.copytree(os.path.expanduser("~/ImageMagick"), dest, True)
        shutil.rmtree(os.path.join(dest, "include"))
        shutil.rmtree(os.path.join(dest, "share", "doc"))
        shutil.rmtree(os.path.join(dest, "share", "man"))
        shutil.copyfile("/usr/local/lib/libpng12.0.dylib", os.path.join(dest, "lib", "libpng12.0.dylib"))
        self.fix_image_magick_deps(dest)

        info("Installing prescipt")
        sf = [os.path.basename(s) for s in all_names]
        launcher_path = os.path.join(resource_dir, "__boot__.py")
        f = open(launcher_path, "r")
        src = f.read()
        f.close()
        src = src.replace("import Image", "from PIL import Image")
        src = re.sub(
            "(_run\s*\(.*?.py.*?\))",
            "%s"
            % (
                """
sys.frameworks_dir = os.path.join(os.path.dirname(os.environ['RESOURCEPATH']), 'Frameworks')
sys.resources_location = os.path.join(os.environ['RESOURCEPATH'], 'resources')
sys.extensions_location = os.path.join(sys.frameworks_dir, 'plugins')
devf = os.environ.get('CALIBRE_DEVELOP_FROM', None)
do_devf = devf and os.path.exists(devf)
if do_devf:
    devf = os.path.abspath(devf)
    sys.path.insert(0, devf)
"""
            )
            + r"\n\1",
            src,
        )
        f = open(launcher_path, "w")
        print >> f, "import sys, os"
        f.write(src)
        f.close()

        info("\nAdding main scripts to site-packages")
        f = zipfile.ZipFile(
            os.path.join(
                self.dist_dir,
                APPNAME + ".app",
                "Contents",
                "Resources",
                "lib",
                "python" + sys.version[:3],
                "site-packages.zip",
            ),
            "a",
            zipfile.ZIP_DEFLATED,
        )
        for script in scripts["gui"] + scripts["console"]:
            f.write(script, script.partition("/")[-1])
        f.close()

        info("\nCreating console.app")
        contents_dir = os.path.dirname(resource_dir)
        cc_dir = os.path.join(contents_dir, "console.app", "Contents")
        os.makedirs(cc_dir)
        for x in os.listdir(contents_dir):
            if x == "console.app":
                continue
            if x == "Info.plist":
                plist = plistlib.readPlist(os.path.join(contents_dir, x))
                plist["LSUIElement"] = "1"
                plistlib.writePlist(plist, os.path.join(cc_dir, x))
            else:
                os.symlink(os.path.join("../..", x), os.path.join(cc_dir, x))

        info("\nBuilding disk image")
        BuildAPP.makedmg(os.path.join(self.dist_dir, APPNAME + ".app"), APPNAME + "-" + VERSION)
示例#21
0
文件: setup.py 项目: yaybu/Yaybu.app
 def run(self):
     self.iconfile = "Resources/Yaybu.icns"
     py2app.run(self)
示例#22
0
    def run(self):
        py2app.run(self)
        resource_dir = os.path.join(self.dist_dir,
                                    APPNAME + '.app', 'Contents', 'Resources')
        frameworks_dir = os.path.join(os.path.dirname(resource_dir), 'Frameworks')
        all_scripts = scripts['console'] + scripts['gui']
        all_names   = basenames['console'] + basenames['gui']
        all_modules   = main_modules['console'] + main_modules['gui']
        all_functions = main_functions['console'] + main_functions['gui']

        info('\nAdding resources')
        dest = os.path.join(resource_dir, 'resources')
        if os.path.exists(dest):
            shutil.rmtree(dest)
        shutil.copytree(os.path.join(os.path.dirname(SRC), 'resources'), dest)

        info('\nAdding PoDoFo')
        pdf = glob.glob(os.path.expanduser('/Volumes/sw/podofo/libpodofo*.dylib'))[0]
        shutil.copyfile(pdf, os.path.join(frameworks_dir, os.path.basename(pdf)))

        info('\nAdding poppler')
        popps = []
        for x in ('bin/pdftohtml', 'lib/libpoppler.5.dylib'):
            dest = os.path.join(frameworks_dir, os.path.basename(x))
            popps.append(dest)
            shutil.copy2(os.path.join('/Volumes/sw', x), dest)
        subprocess.check_call(['install_name_tool', '-change',
            '/usr/local/lib/libfontconfig.1.dylib',
            '@executable_path/../Frameworks/libfontconfig.1.dylib',
            os.path.join(frameworks_dir, 'pdftohtml')])
        x ='libpng12.0.dylib'
        shutil.copy2('/usr/local/lib/'+x, frameworks_dir)
        subprocess.check_call(['install_name_tool', '-id',
            '@executable_path/../Frameworks/'+x, os.path.join(frameworks_dir, x)])
        self.fix_misc_dependencies(popps)
        subprocess.check_call(['install_name_tool', '-change',
        '/usr/local/lib/libfontconfig.1.dylib',
        '@executable_path/../Frameworks/libfontconfig.1.dylib', popps[1]])
        subprocess.check_call(['install_name_tool', '-id',
        '@executable_path/../Frameworks/'+os.path.basename(popps[1]), popps[1]])

        loader_path = os.path.join(resource_dir, 'loaders')
        if not os.path.exists(loader_path):
            os.mkdir(loader_path)
        for name, module, function in zip(all_names, all_modules, all_functions):
            path = os.path.join(loader_path, name)
            info('Creating loader:', path)
            f = open(path, 'w')
            f.write(BuildAPP.LOADER_TEMPLATE % dict(module=module,
                                                        function=function))
            f.close()
            os.chmod(path, stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IREAD\
                     |stat.S_IWUSR|stat.S_IROTH|stat.S_IRGRP)


        info('Adding fontconfig')
        for f in glob.glob(os.path.expanduser('~/fontconfig-bundled/*')):
            dest = os.path.join(frameworks_dir, os.path.basename(f))
            if os.path.exists(dest):
                os.remove(dest)
            shutil.copyfile(f, dest)
        dst = os.path.join(resource_dir, 'fonts')
        if os.path.exists(dst):
            shutil.rmtree(dst)
        shutil.copytree('/usr/local/etc/fonts', dst, symlinks=False)

        self.add_plugins()


        info('Adding IPython')
        dst = os.path.join(resource_dir, 'lib', 'python2.6', 'IPython')
        if os.path.exists(dst): shutil.rmtree(dst)
        shutil.copytree(os.path.expanduser('~/build/ipython/IPython'), dst)


        info('Adding ImageMagick')
        libwmf = '/Volumes/sw/lib/libwmflite-0.2.7.dylib'
        dest = os.path.join(frameworks_dir, os.path.basename(libwmf))
        shutil.copy2(libwmf, frameworks_dir)
        nid = '@executable_path/../Frameworks/'+os.path.basename(dest)
        subprocess.check_call(['install_name_tool', '-id', nid, dest])
        dest = os.path.join(frameworks_dir, 'ImageMagick')
        if os.path.exists(dest):
            shutil.rmtree(dest)
        shutil.copytree(os.path.expanduser('~/ImageMagick'), dest, True)
        shutil.rmtree(os.path.join(dest, 'include'))
        shutil.rmtree(os.path.join(dest, 'share', 'doc'))
        shutil.rmtree(os.path.join(dest, 'share', 'man'))
        shutil.copyfile('/usr/local/lib/libpng12.0.dylib', os.path.join(dest, 'lib', 'libpng12.0.dylib'))
        self.fix_image_magick_deps(dest)


        info('Installing prescipt')
        sf = [os.path.basename(s) for s in all_names]
        launcher_path = os.path.join(resource_dir, '__boot__.py')
        f = open(launcher_path, 'r')
        src = f.read()
        f.close()
        src = src.replace('import Image', 'from PIL import Image')
        src = re.sub('(_run\s*\(.*?.py.*?\))', '%s'%(
'''
sys.frameworks_dir = os.path.join(os.path.dirname(os.environ['RESOURCEPATH']), 'Frameworks')
sys.resources_location = os.path.join(os.environ['RESOURCEPATH'], 'resources')
sys.extensions_location = os.path.join(sys.frameworks_dir, 'plugins')
devf = os.environ.get('CALIBRE_DEVELOP_FROM', None)
do_devf = devf and os.path.exists(devf)
if do_devf:
    devf = os.path.abspath(devf)
    sys.path.insert(0, devf)
''') + r'\n\1', src)
        f = open(launcher_path, 'w')
        print >>f, 'import sys, os'
        f.write(src)
        f.close()

        info('\nAdding main scripts to site-packages')
        f = zipfile.ZipFile(os.path.join(self.dist_dir, APPNAME+'.app', 'Contents', 'Resources', 'lib', 'python'+sys.version[:3], 'site-packages.zip'), 'a', zipfile.ZIP_DEFLATED)
        for script in scripts['gui']+scripts['console']:
            f.write(script, script.partition('/')[-1])
        f.close()

        info('\nCreating console.app')
        contents_dir = os.path.dirname(resource_dir)
        cc_dir = os.path.join(contents_dir, 'console.app', 'Contents')
        os.makedirs(cc_dir)
        for x in os.listdir(contents_dir):
            if x == 'console.app':
                continue
            if x == 'Info.plist':
                plist = plistlib.readPlist(os.path.join(contents_dir, x))
                plist['LSUIElement'] = '1'
                plistlib.writePlist(plist, os.path.join(cc_dir, x))
            else:
                os.symlink(os.path.join('../..', x),
                           os.path.join(cc_dir, x))

        info('\nBuilding disk image')
        BuildAPP.makedmg(os.path.join(self.dist_dir, APPNAME+'.app'), APPNAME+'-'+VERSION)
示例#23
0
文件: setup.py 项目: b333z/picard
 def run(self):
     py2app.run(self)