123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- """
- This is a setup.py script generated by py2applet
- Usage:
- python2.7 setup.py py2app
- """
- import sys
- import glob
- import os
- import plistlib
- import shutil
- import subprocess
- from setuptools import setup
- from setuptools.extension import Extension
- from distutils.file_util import copy_file
- from distutils.dir_util import mkpath
- from py2app.build_app import py2app as py2app_cmd
- if sys.version < '2.7':
- raise RuntimeError('LVC requires Python 2.7')
- APP = ['lvc/osx/app_main.py']
- DATA_FILES = ['lvc/widgets/osx/Resources-Widgets/MainMenu.nib']
- OPTIONS = {
- 'iconfile': os.path.join(SETUP_DIR, 'lvc3.icns'),
- 'excludes': ['lvc.widgets.gtk'],
- 'includes': ['lvc.widgets.osx.fasttypes'],
- 'packages': ['lvc', 'lvc.widgets', 'lvc.widgets.osx', 'lvc.ui',
- 'lvc.qtfaststart', 'lvc.resources']
- }
- # this should work if run from build.sh
- BKIT_DIR = os.environ['BKIT_PATH']
- def copy_binaries(source, target, binaries):
- mkpath(target)
- for mem in binaries:
- src = os.path.join(BKIT_DIR, source, mem)
- if os.path.islink(src):
- dst = os.path.join(target, mem)
- linkto = os.readlink(src)
- if os.path.exists(dst):
- os.remove(dst)
- os.symlink(linkto, dst)
- else:
- copy_file(src, target, update=True)
- def extract_tarball(tar_file, target_directory):
- subprocess.check_call(["tar", "-C", target_directory, "-zxf", tar_file])
- class py2app_lvc(py2app_cmd):
- 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()
- def setup_directories(self):
- self.bundle_root = os.path.join(self.dist_dir,
- 'Libre Video Converter.app/Contents')
- self.helpers_root = os.path.join(self.bundle_root, 'Helpers')
- self.frameworks_root = os.path.join(self.bundle_root, 'Frameworks')
- self.resources_root = os.path.join(self.bundle_root, 'Resources')
- self.python_lib_root = os.path.join(self.resources_root, 'lib',
- 'python2.7')
- if os.path.exists(self.helpers_root):
- shutil.rmtree(self.helpers_root)
- os.mkdir(self.helpers_root)
- def copy_ffmpeg(self):
- 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/', self.helpers_root, ffmpeg_files)
- def copy_sparkle(self):
- tarball = os.path.join(BKIT_DIR, "frameworks", "sparkle.1.5b6.tar.gz")
- extract_tarball(tarball, self.frameworks_root)
- def copy_update_public_key(self):
- src = os.path.join(SETUP_DIR, "sparkle-keys", "dsa_pub.pem")
- target = os.path.join(self.resources_root, 'dsa_pub.pem')
- copy_file(src, target, update=True)
- def delete_site_py(self):
- """Delete the site.py symlink.
- This causes issues with codesigning on 10.8 -- possibly because it's a
- symlink that links to a location outside the resources dir. In any
- case, it's not needed, so let's just nuke it.
- """
- os.unlink(os.path.join(self.python_lib_root, 'site.py'))
- plist = plistlib.readPlist(os.path.join(SETUP_DIR, 'Info.plist'))
- plist['NSHumanReadableCopyright'] = 'Copyright (C) Jesús E.'
- plist['CFBundleGetInfoString'] = 'Libre Video Converter'
- plist['CFBundleIdentifier'] = 'org.participatoryculture.MiroVideoConverter'
- plist['CFBundleShortVersionString'] = '1.1'
- plist['CFBundleExecutable'] = 'Libre Video Converter'
- plist['CFBundleName'] = 'Libre Video Converter'
- plist['CFBundleVersion'] = '1.1.0'
- plist['SUFeedURL'] = ('http://miro-updates.participatoryculture.org/'
- 'lvc-appcast-osx.xml')
- plist['SUPublicDSAKeyFile'] = 'dsa_pub.pem'
- OPTIONS['plist'] = plist
- setup(
- app=APP,
- data_files=DATA_FILES,
- options={'py2app': OPTIONS},
- setup_requires=['py2app'],
- cmdclass={'py2app': py2app_lvc},
- ext_modules=[
- Extension("lvc.widgets.osx.fasttypes",
- [
- os.path.join(
- ROOT_DIR,
- 'lvc', 'widgets',
- 'osx', 'fasttypes.c'
- )
- ])
- ],
- **SETUP_ARGS
- )
|