/
setup.py
112 lines (87 loc) · 2.99 KB
/
setup.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
107
108
109
110
111
112
import os.path
import shutil
import sys
import genlisttypes
from wxpybuild.wxpyext import build_extension, WXWIN
wxpy_extra_sources = '''\
src/PythonUtils.cpp
'''.split()
wxpy_modules = [
('_wxcore', ['src/wx.sip'] + wxpy_extra_sources),
# TODO: use wxUSE_XXX flags
# ('_wxhtml', ['src/html.sip']),
('_wxcalendar', ['src/calendar.sip']),
# ('_wxcombo', ['src/combo.sip']),
('_wxstc', ['contrib/stc/stc.sip']),
]
if not '--nowk' in sys.argv:
wxpy_modules.append(('_webview', ['src/webview.sip']))
BUILDING_WK = True
else:
sys.argv.remove('--nowk')
BUILDING_WK = False
DEBUG = os.path.splitext(sys.executable)[0].endswith('_d')
def get_webkit_dir():
from path import path
for arg in sys.argv[:]:
if arg.startswith('--webkit='):
WEBKITDIR = path(arg[len('--webkit='):])
break
else:
WEBKITDIR = path(os.environ.get('WEBKITDIR', 'webkit'))
if not WEBKITDIR.isdir():
raise Exception('%r is not a valid path\nplease set WEBKITDIR in the environment or pass --webkit=PATH to this script' % str(WEBKITDIR))
return WEBKITDIR
def fatal(msg, returncode = -1):
print >> sys.stderr, msg
sys.exit(returncode)
def main():
genlisttypes.generate()
opts = {}
if BUILDING_WK:
WEBKITDIR = get_webkit_dir()
WEBKITBUILD = WEBKITDIR / 'WebKitBuild'
wk_libdir = WEBKITBUILD / ('Release' if not DEBUG else 'Debug')
wk_lib = wk_libdir / 'wxwebkit.lib'
if os.name == 'nt' and not wk_lib.isfile():
print 'could not find webkit libraries in %s' % wk_libdir
opts.update(includes = [WEBKITDIR / 'WebKit'],
libs = ['wxwebkit'],
libdirs = [wk_libdir] + os.environ.get('LIB', '').split(os.pathsep))
from path import path
outputdir = path('wx').abspath()
assert outputdir.isdir()
opts['outputdir'] = outputdir
build_extension('wxpy', wxpy_modules, **opts)
def windows_install_pyds():
srcdir = 'build/obj-msvs2008prj'
srcdir += '_d/' if DEBUG else '/'
destdir = 'wx/'
print 'copying binaries from %s to %s:' % (srcdir, destdir)
for name, sources in wxpy_modules:
if DEBUG:
name = name + '_d'
for ext in ('.pyd', '.pdb'):
print ' %s%s' % (name, ext)
copy_with_prompt('%s%s%s' % (srcdir, name, ext),
'%s%s%s' % (destdir, name, ext))
def copy_with_prompt(src, dest):
try_again = True
while try_again:
try:
shutil.copy2(src, dest)
except IOError, e:
print e
inp = raw_input('Retry? [Y|n] ')
if inp and not inp.startswith('y'):
raise SystemExit(1)
else:
try_again = True
else:
try_again = False
if __name__ == '__main__':
from traceback import print_exc
import sys
try: main()
except SystemExit: raise
except: print_exc(); sys.exit(1)