forked from bumps/bumps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_py2app.py
106 lines (86 loc) · 2.94 KB
/
setup_py2app.py
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
# This program is in the public domain.
"""
Setup file for constructing OS X applications.
Run using::
% python setup_py2app.py
"""
import os
import sys
import shutil
# Force build before continuing
os.system('"%s" setup.py build'%sys.executable)
# Remove the current directory from the python path
here = os.path.abspath(os.path.dirname(__file__))
sys.path = [p for p in sys.path if os.path.abspath(p) != here]
import py2app
from distutils.core import setup
from distutils.util import get_platform
if len(sys.argv) == 1:
sys.argv.append('py2app')
# Put the build lib on the start of the path.
# For packages with binary extensions, need platform. If it is a pure
# script library, use an empty platform string.
platform = '.%s-%s'%(get_platform(),sys.version[:3])
#platform = ''
build_lib = os.path.abspath('build/lib'+platform)
sys.path.insert(0, build_lib)
#print "\n".join(sys.path)
# TODO: Combine with setup-py2exe so that consistency is easier.
packages = ['numpy', 'scipy', 'matplotlib', 'pytz',
'periodictable', 'dream'
]
includes = []
excludes = ['Tkinter', 'PyQt4', '_ssl', '_tkagg', 'numpy.distutils.test']
PACKAGE_DATA = {}
import bumps
from bumps.gui.resources import resources as gui_resources
NAME = 'Bumps'
# Until we figure out why packages=... doesn't work reliably,
# use py2app_main with explicit imports of everything we
# might need.
#SCRIPT = 'py2app_main.py'
SCRIPT = 'bin/bumps_gui.py'
VERSION = bumps.__version__
ICON = 'extra/bumps.icns'
ID = 'Bumps'
COPYRIGHT = 'This program is public domain'
DATA_FILES = gui_resources.data_files()
plist = dict(
CFBundleIconFile = ICON,
CFBundleName = NAME,
CFBundleShortVersionString = ' '.join([NAME, VERSION]),
CFBundleGetInfoString = NAME,
CFBundleExecutable = NAME,
CFBundleIdentifier = 'gov.nist.ncnr.%s' % ID,
NSHumanReadableCopyright = COPYRIGHT
)
app_data = dict(script=SCRIPT, plist=plist)
py2app_opt = dict(argv_emulation=True,
packages=packages,
includes=includes,
excludes=excludes,
iconfile=ICON,
optimize=2)
options = dict(py2app=py2app_opt,)
def build_app():
setup(
data_files = DATA_FILES,
package_data = PACKAGE_DATA,
app = [app_data],
options = options,
)
def build_dmg():
"""DMG builder; should include docs"""
PRODUCT = NAME+" "+VERSION
PRODUCTDASH = NAME+"-"+VERSION
APP="dist/%s.app"%PRODUCT
DMG="dist/%s.dmg"%PRODUCTDASH
# Remove previous build if it is still sitting there
if os.path.exists(APP): shutil.rmtree(APP)
if os.path.exists(DMG): os.unlink(DMG)
os.rename("dist/%s.app"%NAME, APP)
os.system('cd dist && ../extra/dmgpack.sh "%s" "%s.app" ../doc/_build/html ../doc/examples'%(PRODUCTDASH,PRODUCT))
os.system('chmod a+r "%s"'%DMG)
if __name__ == "__main__":
build_app()
build_dmg()