1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
"""
This is a setup.py script generated by py2applet
Usage:
python2.7 setup.py py2app
"""
import sys
if sys.version < '2.7':
raise RuntimeError('MVC requires Python 2.7')
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
APP = ['mvc/osx/app_main.py']
DATA_FILES = ['mvc/widgets/osx/Resources-Widgets/MainMenu.nib']
OPTIONS = {
'iconfile': os.path.join(SETUP_DIR, 'mvc3.icns'),
'excludes': ['mvc.widgets.gtk'],
'includes': ['mvc.widgets.osx.fasttypes'],
'packages': ['mvc', 'mvc.widgets', 'mvc.widgets.osx', 'mvc.ui',
'mvc.qtfaststart', 'mvc.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_mvc(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,
'Miro 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) Participatory Culture Foundation'
plist['CFBundleGetInfoString'] = 'Miro Video Converter'
plist['CFBundleIdentifier'] = 'org.participatoryculture.MiroVideoConverter'
plist['CFBundleShortVersionString'] = '3.0'
plist['CFBundleExecutable'] = 'Miro Video Converter'
plist['CFBundleName'] = 'Miro Video Converter'
plist['CFBundleVersion'] = '3.0'
plist['SUFeedURL'] = ('http://miro-updates.participatoryculture.org/'
'mvc-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_mvc},
ext_modules=[
Extension("mvc.widgets.osx.fasttypes",
[os.path.join(ROOT_DIR, 'mvc', 'widgets', 'osx', 'fasttypes.c')])],
**SETUP_ARGS
)
|