]>
Commit | Line | Data |
---|---|---|
c368d904 RD |
1 | #!/usr/bin/env python |
2 | #---------------------------------------------------------------------- | |
3 | ||
b0640a71 | 4 | import sys, os, glob, fnmatch, tempfile |
c368d904 RD |
5 | from distutils.core import setup, Extension |
6 | from distutils.file_util import copy_file | |
7 | from distutils.dir_util import mkpath | |
8 | from distutils.dep_util import newer | |
1e4a197e RD |
9 | from distutils.spawn import spawn |
10 | from distutils.command.install_data import install_data | |
c368d904 RD |
11 | |
12 | #---------------------------------------------------------------------- | |
13 | # flags and values that affect this script | |
14 | #---------------------------------------------------------------------- | |
15 | ||
1fded56b RD |
16 | VER_MAJOR = 2 # The first three must match wxWindows |
17 | VER_MINOR = 5 | |
4326f7b7 | 18 | VER_RELEASE = 1 |
1fded56b | 19 | VER_SUBREL = 0 # wxPython release num for x.y.z release of wxWindows |
c6281ceb | 20 | VER_FLAGS = "p6" # release flags, such as prerelease num, unicode, etc. |
1fded56b | 21 | |
c368d904 RD |
22 | DESCRIPTION = "Cross platform GUI toolkit for Python" |
23 | AUTHOR = "Robin Dunn" | |
b166c703 | 24 | AUTHOR_EMAIL = "Robin Dunn <robin@alldunn.com>" |
c368d904 | 25 | URL = "http://wxPython.org/" |
851d4ac7 RD |
26 | DOWNLOAD_URL = "http://wxPython.org/download.php" |
27 | LICENSE = "wxWindows Library License (LGPL derivative)" | |
28 | PLATFORMS = "WIN32,OSX,POSIX" | |
29 | KEYWORDS = "GUI,wx,wxWindows,cross-platform" | |
30 | ||
c368d904 RD |
31 | LONG_DESCRIPTION = """\ |
32 | wxPython is a GUI toolkit for Python that is a wrapper around the | |
33 | wxWindows C++ GUI library. wxPython provides a large variety of | |
1b62f00d | 34 | window types and controls, all implemented with a native look and |
1e4a197e | 35 | feel (by using the native widgets) on the platforms it is supported |
c368d904 RD |
36 | on. |
37 | """ | |
38 | ||
851d4ac7 RD |
39 | CLASSIFIERS = """\ |
40 | Development Status :: 6 - Mature | |
41 | Environment :: MacOS X :: Carbon | |
42 | Environment :: Win32 (MS Windows) | |
43 | Environment :: X11 Applications :: GTK | |
44 | Intended Audience :: Developers | |
45 | License :: OSI Approved | |
46 | Operating System :: MacOS :: MacOS X | |
47 | Operating System :: Microsoft :: Windows :: Windows 95/98/2000 | |
48 | Operating System :: POSIX | |
49 | Programming Language :: Python | |
50 | Topic :: Software Development :: User Interfaces | |
51 | """ | |
52 | ||
53 | ## License :: OSI Approved :: wxWindows Library Licence | |
54 | ||
c368d904 | 55 | |
1e4a197e RD |
56 | # Config values below this point can be reset on the setup.py command line. |
57 | ||
f221f8eb | 58 | BUILD_GLCANVAS = 1 # If true, build the contrib/glcanvas extension module |
c368d904 RD |
59 | BUILD_OGL = 1 # If true, build the contrib/ogl extension module |
60 | BUILD_STC = 1 # If true, build the contrib/stc extension module | |
d56cebe7 | 61 | BUILD_XRC = 1 # XML based resource system |
ebf4302c | 62 | BUILD_GIZMOS = 1 # Build a module for the gizmos contrib library |
1e4a197e | 63 | BUILD_DLLWIDGET = 0# Build a module that enables unknown wx widgets |
37bd51c0 | 64 | # to be loaded from a DLL and to be used from Python. |
d56cebe7 | 65 | |
c731eb47 | 66 | # Internet Explorer wrapper (experimental) |
de7b7fe6 | 67 | BUILD_IEWIN = (os.name == 'nt') |
78e8819c | 68 | |
1e4a197e | 69 | |
c368d904 | 70 | CORE_ONLY = 0 # if true, don't build any of the above |
4a61305d | 71 | |
1e4a197e | 72 | PREP_ONLY = 0 # Only run the prepatory steps, not the actual build. |
c368d904 RD |
73 | |
74 | USE_SWIG = 0 # Should we actually execute SWIG, or just use the | |
75 | # files already in the distribution? | |
76 | ||
d14a1e28 RD |
77 | SWIG = "swig" # The swig executable to use. |
78 | ||
79 | BUILD_RENAMERS = 1 # Should we build the renamer modules too? | |
80 | ||
a541c325 RD |
81 | UNICODE = 0 # This will pass the 'wxUSE_UNICODE' flag to SWIG and |
82 | # will ensure that the right headers are found and the | |
83 | # right libs are linked. | |
c8bc7bb8 | 84 | |
5c8e1089 RD |
85 | UNDEF_NDEBUG = 1 # Python 2.2 on Unix/Linux by default defines NDEBUG, |
86 | # and distutils will pick this up and use it on the | |
87 | # compile command-line for the extensions. This could | |
88 | # conflict with how wxWindows was built. If NDEBUG is | |
89 | # set then wxWindows' __WXDEBUG__ setting will be turned | |
90 | # off. If wxWindows was actually built with it turned | |
91 | # on then you end up with mismatched class structures, | |
92 | # and wxPython will crash. | |
93 | ||
2eb31f8b RD |
94 | NO_SCRIPTS = 0 # Don't install the tool scripts |
95 | ||
1e4a197e RD |
96 | WX_CONFIG = None # Usually you shouldn't need to touch this, but you can set |
97 | # it to pass an alternate version of wx-config or alternate | |
98 | # flags, eg. as required by the .deb in-tree build. By | |
99 | # default a wx-config command will be assembled based on | |
100 | # version, port, etc. and it will be looked for on the | |
101 | # default $PATH. | |
102 | ||
103 | WXPORT = 'gtk' # On Linux/Unix there are several ports of wxWindows available. | |
104 | # Setting this value lets you select which will be used for | |
105 | # the wxPython build. Possibilites are 'gtk', 'gtk2' and | |
106 | # 'x11'. Curently only gtk and gtk2 works. | |
107 | ||
108 | BUILD_BASE = "build" # Directory to use for temporary build files. | |
2eb31f8b | 109 | |
c368d904 | 110 | |
a541c325 | 111 | |
c368d904 RD |
112 | # Some MSW build settings |
113 | ||
d440a0e7 | 114 | FINAL = 0 # Mirrors use of same flag in wx makefiles, |
c368d904 RD |
115 | # (0 or 1 only) should probably find a way to |
116 | # autodetect this... | |
117 | ||
d440a0e7 | 118 | HYBRID = 1 # If set and not debug or FINAL, then build a |
c368d904 RD |
119 | # hybrid extension that can be used by the |
120 | # non-debug version of python, but contains | |
121 | # debugging symbols for wxWindows and wxPython. | |
122 | # wxWindows must have been built with /MD, not /MDd | |
123 | # (using FINAL=hybrid will do it.) | |
124 | ||
3e46a8e6 RD |
125 | # Version part of wxWindows LIB/DLL names |
126 | WXDLLVER = '%d%d' % (VER_MAJOR, VER_MINOR) | |
c368d904 RD |
127 | |
128 | ||
cfe766c3 RD |
129 | #---------------------------------------------------------------------- |
130 | ||
131 | def msg(text): | |
132 | if __name__ == "__main__": | |
133 | print text | |
134 | ||
a541c325 | 135 | |
55c020cf RD |
136 | def opj(*args): |
137 | path = apply(os.path.join, args) | |
138 | return os.path.normpath(path) | |
cfe766c3 | 139 | |
a541c325 | 140 | |
a4fbdd76 RD |
141 | def libFlag(): |
142 | if FINAL: | |
c8bc7bb8 | 143 | rv = '' |
a4fbdd76 | 144 | elif HYBRID: |
c8bc7bb8 | 145 | rv = 'h' |
a4fbdd76 | 146 | else: |
c8bc7bb8 | 147 | rv = 'd' |
a541c325 | 148 | if UNICODE: |
c8bc7bb8 RD |
149 | rv = 'u' + rv |
150 | return rv | |
a4fbdd76 RD |
151 | |
152 | ||
c368d904 RD |
153 | #---------------------------------------------------------------------- |
154 | # Some other globals | |
155 | #---------------------------------------------------------------------- | |
156 | ||
d14a1e28 | 157 | PKGDIR = 'wx' |
c368d904 | 158 | wxpExtensions = [] |
1e4a197e | 159 | DATA_FILES = [] |
c368d904 RD |
160 | |
161 | force = '--force' in sys.argv or '-f' in sys.argv | |
162 | debug = '--debug' in sys.argv or '-g' in sys.argv | |
ce8f00f3 RD |
163 | cleaning = 'clean' in sys.argv |
164 | ||
c368d904 | 165 | |
1e4a197e RD |
166 | # change the PORT default for wxMac |
167 | if sys.platform[:6] == "darwin": | |
168 | WXPORT = 'mac' | |
22d08289 | 169 | |
1e4a197e RD |
170 | # and do the same for wxMSW, just for consistency |
171 | if os.name == 'nt': | |
172 | WXPORT = 'msw' | |
22d08289 | 173 | |
c368d904 RD |
174 | |
175 | #---------------------------------------------------------------------- | |
176 | # Check for build flags on the command line | |
177 | #---------------------------------------------------------------------- | |
178 | ||
5c8e1089 | 179 | # Boolean (int) flags |
b166c703 | 180 | for flag in ['BUILD_GLCANVAS', 'BUILD_OGL', 'BUILD_STC', 'BUILD_XRC', |
c731eb47 | 181 | 'BUILD_GIZMOS', 'BUILD_DLLWIDGET', 'BUILD_IEWIN', |
d14a1e28 RD |
182 | 'CORE_ONLY', 'PREP_ONLY', 'USE_SWIG', 'UNICODE', |
183 | 'UNDEF_NDEBUG', 'NO_SCRIPTS', 'BUILD_RENAMERS', | |
b166c703 | 184 | 'FINAL', 'HYBRID', ]: |
c368d904 | 185 | for x in range(len(sys.argv)): |
1e4a197e RD |
186 | if sys.argv[x].find(flag) == 0: |
187 | pos = sys.argv[x].find('=') + 1 | |
c368d904 RD |
188 | if pos > 0: |
189 | vars()[flag] = eval(sys.argv[x][pos:]) | |
190 | sys.argv[x] = '' | |
191 | ||
5c8e1089 | 192 | # String options |
d14a1e28 | 193 | for option in ['WX_CONFIG', 'WXDLLVER', 'BUILD_BASE', 'WXPORT', 'SWIG']: |
afa3e1ed | 194 | for x in range(len(sys.argv)): |
1e4a197e RD |
195 | if sys.argv[x].find(option) == 0: |
196 | pos = sys.argv[x].find('=') + 1 | |
afa3e1ed RL |
197 | if pos > 0: |
198 | vars()[option] = sys.argv[x][pos:] | |
199 | sys.argv[x] = '' | |
200 | ||
c368d904 RD |
201 | sys.argv = filter(None, sys.argv) |
202 | ||
203 | ||
1e4a197e RD |
204 | #---------------------------------------------------------------------- |
205 | # some helper functions | |
206 | #---------------------------------------------------------------------- | |
207 | ||
208 | def Verify_WX_CONFIG(): | |
209 | """ Called below for the builds that need wx-config, | |
210 | if WX_CONFIG is not set then tries to select the specific | |
211 | wx*-config script based on build options. If not found | |
212 | then it defaults to 'wx-config'. | |
213 | """ | |
214 | # if WX_CONFIG hasn't been set to an explicit value then construct one. | |
215 | global WX_CONFIG | |
216 | if WX_CONFIG is None: | |
217 | if debug: # TODO: Fix this. wxPython's --debug shouldn't be tied to wxWindows... | |
218 | df = 'd' | |
219 | else: | |
220 | df = '' | |
221 | if UNICODE: | |
222 | uf = 'u' | |
223 | else: | |
224 | uf = '' | |
1fded56b | 225 | ver2 = "%s.%s" % (VER_MAJOR, VER_MINOR) |
f87da722 RD |
226 | port = WXPORT |
227 | if port == "x11": | |
228 | port = "x11univ" | |
229 | WX_CONFIG = 'wx%s%s%s-%s-config' % (port, uf, df, ver2) | |
1e4a197e RD |
230 | |
231 | searchpath = os.environ["PATH"] | |
232 | for p in searchpath.split(':'): | |
233 | fp = os.path.join(p, WX_CONFIG) | |
234 | if os.path.exists(fp) and os.access(fp, os.X_OK): | |
235 | # success | |
236 | msg("Found wx-config: " + fp) | |
237 | WX_CONFIG = fp | |
238 | break | |
239 | else: | |
240 | msg("WX_CONFIG not specified and %s not found on $PATH " | |
241 | "defaulting to \"wx-config\"" % WX_CONFIG) | |
242 | WX_CONFIG = 'wx-config' | |
243 | ||
244 | ||
245 | ||
246 | def run_swig(files, dir, gendir, package, USE_SWIG, force, swig_args, swig_deps=[]): | |
247 | """Run SWIG the way I want it done""" | |
d14a1e28 | 248 | |
1e4a197e RD |
249 | if not os.path.exists(os.path.join(dir, gendir)): |
250 | os.mkdir(os.path.join(dir, gendir)) | |
251 | ||
8994c3c2 RD |
252 | if not os.path.exists(os.path.join("docs", "xml-raw")): |
253 | os.mkdir(os.path.join("docs", "xml-raw")) | |
254 | ||
1e4a197e RD |
255 | sources = [] |
256 | ||
257 | for file in files: | |
258 | basefile = os.path.splitext(file)[0] | |
259 | i_file = os.path.join(dir, file) | |
260 | py_file = os.path.join(dir, gendir, basefile+'.py') | |
d14a1e28 | 261 | cpp_file = os.path.join(dir, gendir, basefile+'_wrap.cpp') |
8994c3c2 | 262 | xml_file = os.path.join("docs", "xml-raw", basefile+'_swig.xml') |
1e4a197e RD |
263 | |
264 | sources.append(cpp_file) | |
265 | ||
ce8f00f3 | 266 | if not cleaning and USE_SWIG: |
1e4a197e RD |
267 | for dep in swig_deps: |
268 | if newer(dep, py_file) or newer(dep, cpp_file): | |
269 | force = 1 | |
270 | break | |
271 | ||
272 | if force or newer(i_file, py_file) or newer(i_file, cpp_file): | |
d14a1e28 RD |
273 | ## we need forward slashes here even on win32 |
274 | #cpp_file = opj(cpp_file) #'/'.join(cpp_file.split('\\')) | |
275 | #i_file = opj(i_file) #'/'.join(i_file.split('\\')) | |
276 | ||
277 | if BUILD_RENAMERS: | |
b0640a71 RD |
278 | #tempfile.tempdir = sourcePath |
279 | xmltemp = tempfile.mktemp('.xml') | |
280 | ||
8994c3c2 RD |
281 | # First run swig to produce the XML file, adding |
282 | # an extra -D that prevents the old rename | |
283 | # directives from being used | |
284 | cmd = [ swig_cmd ] + swig_args + \ | |
b0640a71 | 285 | [ '-DBUILDING_RENAMERS', '-xmlout', xmltemp ] + \ |
8994c3c2 RD |
286 | ['-I'+dir, '-o', cpp_file, i_file] |
287 | msg(' '.join(cmd)) | |
288 | spawn(cmd) | |
289 | ||
290 | # Next run build_renamers to process the XML | |
d14a1e28 | 291 | cmd = [ sys.executable, '-u', |
b0640a71 | 292 | './distrib/build_renamers.py', dir, basefile, xmltemp] |
d14a1e28 RD |
293 | msg(' '.join(cmd)) |
294 | spawn(cmd) | |
b0640a71 | 295 | os.remove(xmltemp) |
d14a1e28 RD |
296 | |
297 | # Then run swig for real | |
b0640a71 RD |
298 | cmd = [ swig_cmd ] + swig_args + ['-I'+dir, '-o', cpp_file, |
299 | '-xmlout', xml_file, i_file] | |
1e4a197e RD |
300 | msg(' '.join(cmd)) |
301 | spawn(cmd) | |
302 | ||
d14a1e28 | 303 | |
1e4a197e RD |
304 | # copy the generated python file to the package directory |
305 | copy_file(py_file, package, update=not force, verbose=0) | |
306 | ||
307 | return sources | |
308 | ||
309 | ||
310 | ||
311 | def contrib_copy_tree(src, dest, verbose=0): | |
312 | """Update local copies of wxWindows contrib files""" | |
313 | from distutils.dir_util import mkpath, copy_tree | |
314 | ||
315 | mkpath(dest, verbose=verbose) | |
316 | copy_tree(src, dest, update=1, verbose=verbose) | |
317 | ||
318 | ||
319 | ||
320 | class smart_install_data(install_data): | |
321 | def run(self): | |
322 | #need to change self.install_dir to the actual library dir | |
323 | install_cmd = self.get_finalized_command('install') | |
324 | self.install_dir = getattr(install_cmd, 'install_lib') | |
325 | return install_data.run(self) | |
326 | ||
327 | ||
328 | def build_locale_dir(destdir, verbose=1): | |
329 | """Build a locale dir under the wxPython package for MSW""" | |
330 | moFiles = glob.glob(opj(WXDIR, 'locale', '*.mo')) | |
331 | for src in moFiles: | |
332 | lang = os.path.splitext(os.path.basename(src))[0] | |
333 | dest = opj(destdir, lang, 'LC_MESSAGES') | |
334 | mkpath(dest, verbose=verbose) | |
335 | copy_file(src, opj(dest, 'wxstd.mo'), update=1, verbose=verbose) | |
336 | ||
337 | ||
338 | def build_locale_list(srcdir): | |
339 | # get a list of all files under the srcdir, to be used for install_data | |
340 | def walk_helper(lst, dirname, files): | |
341 | for f in files: | |
342 | filename = opj(dirname, f) | |
343 | if not os.path.isdir(filename): | |
344 | lst.append( (dirname, [filename]) ) | |
345 | file_list = [] | |
346 | os.path.walk(srcdir, walk_helper, file_list) | |
347 | return file_list | |
348 | ||
349 | ||
1fded56b RD |
350 | def find_data_files(srcdir, *wildcards): |
351 | # get a list of all files under the srcdir matching wildcards, | |
352 | # returned in a format to be used for install_data | |
353 | ||
354 | def walk_helper(arg, dirname, files): | |
355 | names = [] | |
356 | lst, wildcards = arg | |
357 | for wc in wildcards: | |
358 | for f in files: | |
359 | filename = opj(dirname, f) | |
360 | if fnmatch.fnmatch(filename, wc) and not os.path.isdir(filename): | |
361 | names.append(filename) | |
362 | if names: | |
363 | lst.append( (dirname, names ) ) | |
364 | ||
365 | file_list = [] | |
366 | os.path.walk(srcdir, walk_helper, (file_list, wildcards)) | |
367 | return file_list | |
1e4a197e RD |
368 | |
369 | ||
3ef86e32 RD |
370 | def makeLibName(name): |
371 | if os.name == 'posix': | |
372 | libname = '%s_%s-%s' % (WXBASENAME, name, WXRELEASE) | |
373 | else: | |
3e46a8e6 | 374 | libname = 'wxmsw%s%s_%s' % (WXDLLVER, libFlag(), name) |
3ef86e32 RD |
375 | |
376 | return [libname] | |
377 | ||
378 | ||
379 | ||
380 | def adjustCFLAGS(cflags, defines, includes): | |
d14a1e28 | 381 | '''Extrace the raw -I, -D, and -U flags and put them into |
3ef86e32 RD |
382 | defines and includes as needed.''' |
383 | newCFLAGS = [] | |
384 | for flag in cflags: | |
385 | if flag[:2] == '-I': | |
386 | includes.append(flag[2:]) | |
387 | elif flag[:2] == '-D': | |
388 | flag = flag[2:] | |
389 | if flag.find('=') == -1: | |
390 | defines.append( (flag, None) ) | |
391 | else: | |
392 | defines.append( tuple(flag.split('=')) ) | |
393 | elif flag[:2] == '-U': | |
394 | defines.append( (flag[2:], ) ) | |
395 | else: | |
396 | newCFLAGS.append(flag) | |
397 | return newCFLAGS | |
398 | ||
399 | ||
400 | ||
401 | def adjustLFLAGS(lfags, libdirs, libs): | |
d14a1e28 | 402 | '''Extrace the -L and -l flags and put them in libdirs and libs as needed''' |
3ef86e32 RD |
403 | newLFLAGS = [] |
404 | for flag in lflags: | |
405 | if flag[:2] == '-L': | |
406 | libdirs.append(flag[2:]) | |
407 | elif flag[:2] == '-l': | |
408 | libs.append(flag[2:]) | |
409 | else: | |
410 | newLFLAGS.append(flag) | |
411 | ||
412 | return newLFLAGS | |
c8bc7bb8 RD |
413 | |
414 | #---------------------------------------------------------------------- | |
415 | # sanity checks | |
416 | ||
c368d904 | 417 | if CORE_ONLY: |
f221f8eb | 418 | BUILD_GLCANVAS = 0 |
c368d904 RD |
419 | BUILD_OGL = 0 |
420 | BUILD_STC = 0 | |
b166c703 | 421 | BUILD_XRC = 0 |
ff5f1aba RD |
422 | BUILD_GIZMOS = 0 |
423 | BUILD_DLLWIDGET = 0 | |
c731eb47 | 424 | BUILD_IEWIN = 0 |
ff5f1aba | 425 | |
1e4a197e RD |
426 | if debug: |
427 | FINAL = 0 | |
428 | HYBRID = 0 | |
c368d904 | 429 | |
1e4a197e RD |
430 | if FINAL: |
431 | HYBRID = 0 | |
c8bc7bb8 | 432 | |
1e4a197e RD |
433 | if UNICODE and WXPORT not in ['msw', 'gtk2']: |
434 | raise SystemExit, "UNICODE mode not currently supported on this WXPORT: "+WXPORT | |
a541c325 RD |
435 | |
436 | ||
c368d904 RD |
437 | #---------------------------------------------------------------------- |
438 | # Setup some platform specific stuff | |
439 | #---------------------------------------------------------------------- | |
440 | ||
441 | if os.name == 'nt': | |
442 | # Set compile flags and such for MSVC. These values are derived | |
a541c325 RD |
443 | # from the wxWindows makefiles for MSVC, other compilers settings |
444 | # will probably vary... | |
445 | if os.environ.has_key('WXWIN'): | |
446 | WXDIR = os.environ['WXWIN'] | |
447 | else: | |
448 | msg("WARNING: WXWIN not set in environment.") | |
449 | WXDIR = '..' # assumes in CVS tree | |
c368d904 RD |
450 | WXPLAT = '__WXMSW__' |
451 | GENDIR = 'msw' | |
452 | ||
d14a1e28 RD |
453 | includes = ['include', 'src', |
454 | opj(WXDIR, 'lib', 'vc_dll', 'msw' + libFlag()), | |
55c020cf | 455 | opj(WXDIR, 'include'), |
5a2a9da2 | 456 | opj(WXDIR, 'contrib', 'include'), |
c368d904 RD |
457 | ] |
458 | ||
1e4a197e | 459 | defines = [ ('WIN32', None), |
c368d904 | 460 | ('_WINDOWS', None), |
c368d904 RD |
461 | |
462 | (WXPLAT, None), | |
463 | ('WXUSINGDLL', '1'), | |
464 | ||
465 | ('SWIG_GLOBAL', None), | |
c368d904 RD |
466 | ('WXP_USE_THREAD', '1'), |
467 | ] | |
468 | ||
1e4a197e RD |
469 | if UNDEF_NDEBUG: |
470 | defines.append( ('NDEBUG',) ) # using a 1-tuple makes it do an undef | |
22d08289 RD |
471 | |
472 | ||
c368d904 RD |
473 | if not FINAL or HYBRID: |
474 | defines.append( ('__WXDEBUG__', None) ) | |
475 | ||
1e521887 | 476 | libdirs = [ opj(WXDIR, 'lib', 'vc_dll') ] |
0a67b751 RD |
477 | libs = [ 'wxbase' + WXDLLVER + libFlag(), # TODO: trim this down to what is really needed for the core |
478 | 'wxbase' + WXDLLVER + libFlag() + '_net', | |
479 | 'wxbase' + WXDLLVER + libFlag() + '_xml', | |
480 | makeLibName('core')[0], | |
481 | makeLibName('adv')[0], | |
482 | makeLibName('html')[0], | |
483 | ] | |
a4fbdd76 | 484 | |
22d08289 | 485 | libs = libs + ['kernel32', 'user32', 'gdi32', 'comdlg32', |
c368d904 | 486 | 'winspool', 'winmm', 'shell32', 'oldnames', 'comctl32', |
1e4a197e | 487 | 'odbc32', 'ole32', 'oleaut32', 'uuid', 'rpcrt4', |
c368d904 RD |
488 | 'advapi32', 'wsock32'] |
489 | ||
22d08289 | 490 | |
d440a0e7 | 491 | cflags = [ '/Gy', |
ad07d019 RD |
492 | # '/GX-' # workaround for internal compiler error in MSVC on some machines |
493 | ] | |
c368d904 RD |
494 | lflags = None |
495 | ||
1e4a197e | 496 | # Other MSVC flags... |
1fded56b | 497 | # Too bad I don't remember why I was playing with these, can they be removed? |
1e4a197e RD |
498 | if FINAL: |
499 | pass #cflags = cflags + ['/O1'] | |
500 | elif HYBRID : | |
501 | pass #cflags = cflags + ['/Ox'] | |
502 | else: | |
503 | pass # cflags = cflags + ['/Od', '/Z7'] | |
504 | # lflags = ['/DEBUG', ] | |
22d08289 RD |
505 | |
506 | ||
22d08289 | 507 | |
1e4a197e | 508 | #---------------------------------------------------------------------- |
c368d904 | 509 | |
3ef86e32 | 510 | elif os.name == 'posix': |
d14a1e28 RD |
511 | WXDIR = '..' |
512 | includes = ['include', 'src'] | |
e6056257 RD |
513 | defines = [('SWIG_GLOBAL', None), |
514 | ('HAVE_CONFIG_H', None), | |
515 | ('WXP_USE_THREAD', '1'), | |
516 | ] | |
1e4a197e RD |
517 | if UNDEF_NDEBUG: |
518 | defines.append( ('NDEBUG',) ) # using a 1-tuple makes it do an undef | |
1e4a197e RD |
519 | |
520 | Verify_WX_CONFIG() | |
e6056257 | 521 | |
3ef86e32 RD |
522 | libdirs = [] |
523 | libs = [] | |
524 | ||
f9b46bcb RD |
525 | # If you get unresolved symbol errors on Solaris and are using gcc, then |
526 | # uncomment this block to add the right flags to the link step and build | |
527 | # again. | |
528 | ## if os.uname()[0] == 'SunOS': | |
529 | ## libs.append('gcc') | |
530 | ## libdirs.append(commands.getoutput("gcc -print-search-dirs | grep '^install' | awk '{print $2}'")[:-1]) | |
531 | ||
e6056257 | 532 | cflags = os.popen(WX_CONFIG + ' --cxxflags', 'r').read()[:-1] |
1e4a197e | 533 | cflags = cflags.split() |
ba201fa4 RD |
534 | if debug: |
535 | cflags.append('-g') | |
536 | cflags.append('-O0') | |
8b9a4190 RD |
537 | else: |
538 | cflags.append('-O3') | |
e6056257 RD |
539 | |
540 | lflags = os.popen(WX_CONFIG + ' --libs', 'r').read()[:-1] | |
1e4a197e | 541 | lflags = lflags.split() |
e6056257 | 542 | |
3ef86e32 RD |
543 | WXBASENAME = os.popen(WX_CONFIG + ' --basename').read()[:-1] |
544 | WXRELEASE = os.popen(WX_CONFIG + ' --release').read()[:-1] | |
545 | WXPREFIX = os.popen(WX_CONFIG + ' --prefix').read()[:-1] | |
e6056257 RD |
546 | |
547 | ||
3ef86e32 RD |
548 | if sys.platform[:6] == "darwin": |
549 | # Flags and such for a Darwin (Max OS X) build of Python | |
550 | WXPLAT = '__WXMAC__' | |
551 | GENDIR = 'mac' | |
552 | libs = ['stdc++'] | |
553 | NO_SCRIPTS = 1 | |
c368d904 | 554 | |
1e4a197e | 555 | |
3ef86e32 RD |
556 | else: |
557 | # Set flags for other Unix type platforms | |
558 | GENDIR = WXPORT | |
559 | ||
560 | if WXPORT == 'gtk': | |
561 | WXPLAT = '__WXGTK__' | |
562 | portcfg = os.popen('gtk-config --cflags', 'r').read()[:-1] | |
563 | elif WXPORT == 'gtk2': | |
564 | WXPLAT = '__WXGTK__' | |
565 | GENDIR = 'gtk' # no code differences so use the same generated sources | |
566 | portcfg = os.popen('pkg-config gtk+-2.0 --cflags', 'r').read()[:-1] | |
567 | BUILD_BASE = BUILD_BASE + '-' + WXPORT | |
568 | elif WXPORT == 'x11': | |
569 | WXPLAT = '__WXX11__' | |
570 | portcfg = '' | |
571 | BUILD_BASE = BUILD_BASE + '-' + WXPORT | |
572 | else: | |
573 | raise SystemExit, "Unknown WXPORT value: " + WXPORT | |
1e4a197e | 574 | |
3ef86e32 | 575 | cflags += portcfg.split() |
1e4a197e | 576 | |
d14a1e28 RD |
577 | # Some distros (e.g. Mandrake) put libGLU in /usr/X11R6/lib, but |
578 | # wx-config doesn't output that for some reason. For now, just | |
579 | # add it unconditionally but we should really check if the lib is | |
580 | # really found there or wx-config should be fixed. | |
581 | libdirs.append("/usr/X11R6/lib") | |
c368d904 | 582 | |
1e4a197e | 583 | |
3ef86e32 RD |
584 | # Move the various -I, -D, etc. flags we got from the *config scripts |
585 | # into the distutils lists. | |
586 | cflags = adjustCFLAGS(cflags, defines, includes) | |
587 | lflags = adjustLFLAGS(lflags, libdirs, libs) | |
c368d904 RD |
588 | |
589 | ||
1e4a197e | 590 | #---------------------------------------------------------------------- |
c368d904 | 591 | else: |
1e4a197e RD |
592 | raise 'Sorry Charlie, platform not supported...' |
593 | ||
594 | ||
595 | #---------------------------------------------------------------------- | |
1fded56b | 596 | # post platform setup checks and tweaks, create the full version string |
1e4a197e RD |
597 | #---------------------------------------------------------------------- |
598 | ||
599 | if UNICODE: | |
600 | BUILD_BASE = BUILD_BASE + '.unicode' | |
1fded56b | 601 | VER_FLAGS += 'u' |
c368d904 RD |
602 | |
603 | ||
1fded56b RD |
604 | VERSION = "%s.%s.%s.%s%s" % (VER_MAJOR, VER_MINOR, VER_RELEASE, |
605 | VER_SUBREL, VER_FLAGS) | |
606 | ||
c368d904 | 607 | #---------------------------------------------------------------------- |
1fded56b | 608 | # Update the version file |
c368d904 RD |
609 | #---------------------------------------------------------------------- |
610 | ||
1fded56b RD |
611 | # Unconditionally updated since the version string can change based |
612 | # on the UNICODE flag | |
613 | open('src/__version__.py', 'w').write("""\ | |
614 | # This file was generated by setup.py... | |
615 | ||
d14a1e28 RD |
616 | VERSION_STRING = '%(VERSION)s' |
617 | MAJOR_VERSION = %(VER_MAJOR)s | |
618 | MINOR_VERSION = %(VER_MINOR)s | |
619 | RELEASE_VERSION = %(VER_RELEASE)s | |
620 | SUBREL_VERSION = %(VER_SUBREL)s | |
1fded56b | 621 | |
d14a1e28 RD |
622 | VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION, |
623 | SUBREL_VERSION, '%(VER_FLAGS)s') | |
1fded56b | 624 | |
d14a1e28 | 625 | RELEASE_NUMBER = RELEASE_VERSION # for compatibility |
1fded56b | 626 | """ % globals()) |
1e4a197e | 627 | |
c368d904 | 628 | |
1b62f00d RD |
629 | |
630 | ||
c368d904 | 631 | #---------------------------------------------------------------------- |
1b62f00d | 632 | # SWIG defaults |
c368d904 RD |
633 | #---------------------------------------------------------------------- |
634 | ||
d14a1e28 | 635 | swig_cmd = SWIG |
c368d904 | 636 | swig_force = force |
d14a1e28 RD |
637 | swig_args = ['-c++', |
638 | '-Wall', | |
639 | '-nodefault', | |
640 | ||
641 | ## '-xml', | |
642 | ||
643 | '-python', | |
644 | '-keyword', | |
645 | '-new_repr', | |
646 | '-modern', | |
647 | ||
648 | '-I./src', | |
649 | '-D'+WXPLAT, | |
98fb9b71 | 650 | '-noruntime' |
e6056257 | 651 | ] |
a541c325 | 652 | if UNICODE: |
c8bc7bb8 RD |
653 | swig_args.append('-DwxUSE_UNICODE') |
654 | ||
d14a1e28 RD |
655 | swig_deps = [ 'src/my_typemaps.i', |
656 | 'src/common.swg', | |
657 | 'src/pyrun.swg', | |
658 | ] | |
659 | ||
660 | depends = [ #'include/wx/wxPython/wxPython.h', | |
661 | #'include/wx/wxPython/wxPython_int.h', | |
662 | #'src/pyclasses.h', | |
663 | ] | |
c368d904 | 664 | |
c368d904 | 665 | |
1b62f00d RD |
666 | #---------------------------------------------------------------------- |
667 | # Define the CORE extension module | |
668 | #---------------------------------------------------------------------- | |
669 | ||
1e4a197e | 670 | msg('Preparing CORE...') |
d14a1e28 RD |
671 | swig_sources = run_swig(['core.i'], 'src', GENDIR, PKGDIR, |
672 | USE_SWIG, swig_force, swig_args, swig_deps + | |
1e0c8722 RD |
673 | [ 'src/_accel.i', |
674 | 'src/_app.i', | |
d14a1e28 RD |
675 | 'src/_app_ex.py', |
676 | 'src/_constraints.i', | |
677 | 'src/_core_api.i', | |
678 | 'src/_core_ex.py', | |
679 | 'src/_core_rename.i', | |
680 | 'src/_core_reverse.txt', | |
681 | 'src/_defs.i', | |
682 | 'src/_event.i', | |
683 | 'src/_event_ex.py', | |
684 | 'src/_evthandler.i', | |
685 | 'src/_filesys.i', | |
686 | 'src/_gdicmn.i', | |
687 | 'src/_image.i', | |
688 | 'src/_menu.i', | |
689 | 'src/_obj.i', | |
690 | 'src/_sizers.i', | |
691 | 'src/_gbsizer.i', | |
692 | 'src/_streams.i', | |
693 | 'src/_validator.i', | |
694 | 'src/_window.i', | |
695 | ]) | |
1b62f00d | 696 | |
1e4a197e RD |
697 | copy_file('src/__init__.py', PKGDIR, update=1, verbose=0) |
698 | copy_file('src/__version__.py', PKGDIR, update=1, verbose=0) | |
1b62f00d RD |
699 | |
700 | ||
d14a1e28 RD |
701 | # update the license files |
702 | mkpath('licence') | |
703 | for file in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']: | |
704 | copy_file(opj(WXDIR, 'docs', file), opj('licence',file), update=1, verbose=0) | |
c368d904 | 705 | |
c368d904 | 706 | |
1e4a197e RD |
707 | if os.name == 'nt': |
708 | build_locale_dir(opj(PKGDIR, 'locale')) | |
709 | DATA_FILES += build_locale_list(opj(PKGDIR, 'locale')) | |
4f3449b4 RD |
710 | |
711 | ||
1e4a197e RD |
712 | if os.name == 'nt': |
713 | rc_file = ['src/wxc.rc'] | |
714 | else: | |
715 | rc_file = [] | |
716 | ||
717 | ||
d14a1e28 RD |
718 | ext = Extension('_core', ['src/helpers.cpp', |
719 | 'src/libpy.c', | |
1e4a197e RD |
720 | ] + rc_file + swig_sources, |
721 | ||
722 | include_dirs = includes, | |
723 | define_macros = defines, | |
724 | ||
725 | library_dirs = libdirs, | |
726 | libraries = libs, | |
727 | ||
728 | extra_compile_args = cflags, | |
729 | extra_link_args = lflags, | |
d14a1e28 RD |
730 | |
731 | depends = depends | |
1e4a197e RD |
732 | ) |
733 | wxpExtensions.append(ext) | |
734 | ||
735 | ||
d14a1e28 RD |
736 | |
737 | ||
738 | ||
739 | # Extension for the GDI module | |
740 | swig_sources = run_swig(['gdi.i'], 'src', GENDIR, PKGDIR, | |
741 | USE_SWIG, swig_force, swig_args, swig_deps + | |
742 | ['src/_gdi_rename.i', | |
743 | 'src/_bitmap.i', 'src/_brush.i', | |
744 | 'src/_colour.i', 'src/_cursor.i', | |
745 | 'src/_dc.i', 'src/_font.i', | |
746 | 'src/_gdiobj.i', 'src/_icon.i', | |
747 | 'src/_imaglist.i', 'src/_pen.i', | |
748 | 'src/_region.i', 'src/_palette.i', | |
dd9f7fea | 749 | 'src/_stockobjs.i', |
d14a1e28 RD |
750 | 'src/_effects.i', |
751 | 'src/_intl.i', | |
752 | 'src/_intl_ex.py', | |
753 | ]) | |
754 | ext = Extension('_gdi', ['src/drawlist.cpp'] + swig_sources, | |
1e4a197e RD |
755 | include_dirs = includes, |
756 | define_macros = defines, | |
757 | library_dirs = libdirs, | |
758 | libraries = libs, | |
759 | extra_compile_args = cflags, | |
760 | extra_link_args = lflags, | |
d14a1e28 | 761 | depends = depends |
1e4a197e RD |
762 | ) |
763 | wxpExtensions.append(ext) | |
764 | ||
765 | ||
d14a1e28 RD |
766 | |
767 | ||
768 | ||
769 | ||
770 | # Extension for the windows module | |
771 | swig_sources = run_swig(['windows.i'], 'src', GENDIR, PKGDIR, | |
772 | USE_SWIG, swig_force, swig_args, swig_deps + | |
773 | ['src/_windows_rename.i', 'src/_windows_reverse.txt', | |
774 | 'src/_panel.i', | |
d14a1e28 RD |
775 | 'src/_toplvl.i', 'src/_statusbar.i', |
776 | 'src/_splitter.i', 'src/_sashwin.i', | |
777 | 'src/_popupwin.i', 'src/_tipwin.i', | |
778 | 'src/_vscroll.i', 'src/_taskbar.i', | |
779 | 'src/_cmndlgs.i', 'src/_mdi.i', | |
780 | 'src/_pywindows.i', 'src/_printfw.i', | |
781 | ]) | |
782 | ext = Extension('_windows', swig_sources, | |
1e4a197e RD |
783 | include_dirs = includes, |
784 | define_macros = defines, | |
785 | library_dirs = libdirs, | |
786 | libraries = libs, | |
787 | extra_compile_args = cflags, | |
788 | extra_link_args = lflags, | |
d14a1e28 | 789 | depends = depends |
1e4a197e RD |
790 | ) |
791 | wxpExtensions.append(ext) | |
792 | ||
793 | ||
d14a1e28 RD |
794 | |
795 | ||
796 | # Extension for the controls module | |
797 | swig_sources = run_swig(['controls.i'], 'src', GENDIR, PKGDIR, | |
798 | USE_SWIG, swig_force, swig_args, swig_deps + | |
799 | [ 'src/_controls_rename.i', 'src/_controls_reverse.txt', | |
800 | 'src/_control.i', 'src/_toolbar.i', | |
801 | 'src/_button.i', 'src/_checkbox.i', | |
802 | 'src/_choice.i', 'src/_combobox.i', | |
803 | 'src/_gauge.i', 'src/_statctrls.i', | |
804 | 'src/_listbox.i', 'src/_textctrl.i', | |
805 | 'src/_scrolbar.i', 'src/_spin.i', | |
806 | 'src/_radio.i', 'src/_slider.i', | |
807 | 'src/_tglbtn.i', 'src/_notebook.i', | |
808 | 'src/_listctrl.i', 'src/_treectrl.i', | |
809 | 'src/_dirctrl.i', 'src/_pycontrol.i', | |
dd9f7fea | 810 | 'src/_cshelp.i', 'src/_dragimg.i', |
d14a1e28 RD |
811 | ]) |
812 | ext = Extension('_controls', swig_sources, | |
813 | include_dirs = includes, | |
814 | define_macros = defines, | |
815 | library_dirs = libdirs, | |
816 | libraries = libs, | |
817 | extra_compile_args = cflags, | |
818 | extra_link_args = lflags, | |
819 | depends = depends | |
820 | ) | |
821 | wxpExtensions.append(ext) | |
822 | ||
823 | ||
824 | ||
825 | ||
826 | # Extension for the misc module | |
827 | swig_sources = run_swig(['misc.i'], 'src', GENDIR, PKGDIR, | |
828 | USE_SWIG, swig_force, swig_args, swig_deps + | |
829 | [ 'src/_settings.i', 'src/_functions.i', | |
830 | 'src/_misc.i', 'src/_tipdlg.i', | |
831 | 'src/_timer.i', 'src/_log.i', | |
832 | 'src/_process.i', 'src/_joystick.i', | |
833 | 'src/_wave.i', 'src/_mimetype.i', | |
834 | 'src/_artprov.i', 'src/_config.i', | |
835 | 'src/_datetime.i', 'src/_dataobj.i', | |
836 | 'src/_dnd.i', | |
837 | 'src/_clipbrd.i', | |
838 | ]) | |
839 | ext = Extension('_misc', swig_sources, | |
840 | include_dirs = includes, | |
841 | define_macros = defines, | |
842 | library_dirs = libdirs, | |
843 | libraries = libs, | |
844 | extra_compile_args = cflags, | |
845 | extra_link_args = lflags, | |
846 | depends = depends | |
847 | ) | |
848 | wxpExtensions.append(ext) | |
849 | ||
850 | ||
851 | ||
852 | ## | |
853 | ## Core modules that are not in the "core" namespace start here | |
854 | ## | |
855 | ||
1e4a197e RD |
856 | swig_sources = run_swig(['calendar.i'], 'src', GENDIR, PKGDIR, |
857 | USE_SWIG, swig_force, swig_args, swig_deps) | |
d14a1e28 RD |
858 | ext = Extension('_calendar', swig_sources, |
859 | include_dirs = includes, | |
860 | define_macros = defines, | |
861 | library_dirs = libdirs, | |
862 | libraries = libs, | |
863 | extra_compile_args = cflags, | |
864 | extra_link_args = lflags, | |
865 | depends = depends | |
866 | ) | |
867 | wxpExtensions.append(ext) | |
868 | ||
869 | ||
870 | swig_sources = run_swig(['grid.i'], 'src', GENDIR, PKGDIR, | |
871 | USE_SWIG, swig_force, swig_args, swig_deps) | |
872 | ext = Extension('_grid', swig_sources, | |
1e4a197e RD |
873 | include_dirs = includes, |
874 | define_macros = defines, | |
875 | library_dirs = libdirs, | |
876 | libraries = libs, | |
877 | extra_compile_args = cflags, | |
878 | extra_link_args = lflags, | |
d14a1e28 | 879 | depends = depends |
1e4a197e RD |
880 | ) |
881 | wxpExtensions.append(ext) | |
882 | ||
883 | ||
d14a1e28 RD |
884 | |
885 | swig_sources = run_swig(['html.i'], 'src', GENDIR, PKGDIR, | |
1e4a197e | 886 | USE_SWIG, swig_force, swig_args, swig_deps) |
d14a1e28 | 887 | ext = Extension('_html', swig_sources, |
1e4a197e RD |
888 | include_dirs = includes, |
889 | define_macros = defines, | |
890 | library_dirs = libdirs, | |
891 | libraries = libs, | |
892 | extra_compile_args = cflags, | |
893 | extra_link_args = lflags, | |
d14a1e28 | 894 | depends = depends |
1e4a197e RD |
895 | ) |
896 | wxpExtensions.append(ext) | |
897 | ||
898 | ||
d14a1e28 | 899 | |
1e4a197e RD |
900 | swig_sources = run_swig(['wizard.i'], 'src', GENDIR, PKGDIR, |
901 | USE_SWIG, swig_force, swig_args, swig_deps) | |
d14a1e28 | 902 | ext = Extension('_wizard', swig_sources, |
1e4a197e RD |
903 | include_dirs = includes, |
904 | define_macros = defines, | |
905 | library_dirs = libdirs, | |
906 | libraries = libs, | |
907 | extra_compile_args = cflags, | |
908 | extra_link_args = lflags, | |
d14a1e28 | 909 | depends = depends |
1e4a197e RD |
910 | ) |
911 | wxpExtensions.append(ext) | |
af83019e RD |
912 | |
913 | ||
d14a1e28 RD |
914 | |
915 | ||
916 | ||
c368d904 RD |
917 | #---------------------------------------------------------------------- |
918 | # Define the GLCanvas extension module | |
919 | #---------------------------------------------------------------------- | |
920 | ||
1e4a197e | 921 | if BUILD_GLCANVAS: |
cfe766c3 | 922 | msg('Preparing GLCANVAS...') |
c368d904 | 923 | location = 'contrib/glcanvas' |
c368d904 | 924 | |
d14a1e28 | 925 | swig_sources = run_swig(['glcanvas.i'], location, GENDIR, PKGDIR, |
10ef30eb | 926 | USE_SWIG, swig_force, swig_args, swig_deps) |
c368d904 RD |
927 | |
928 | gl_libs = [] | |
929 | if os.name == 'posix': | |
f32afe1c | 930 | gl_config = os.popen(WX_CONFIG + ' --gl-libs', 'r').read()[:-1] |
1e4a197e | 931 | gl_lflags = gl_config.split() + lflags |
f32afe1c | 932 | gl_libs = libs |
19cf4f80 | 933 | else: |
3e46a8e6 | 934 | gl_libs = libs + ['opengl32', 'glu32'] + makeLibName('gl') |
f32afe1c | 935 | gl_lflags = lflags |
c368d904 | 936 | |
d14a1e28 | 937 | ext = Extension('_glcanvas', |
3e46a8e6 | 938 | swig_sources, |
1e7ecb7b RD |
939 | |
940 | include_dirs = includes, | |
941 | define_macros = defines, | |
942 | ||
943 | library_dirs = libdirs, | |
f32afe1c | 944 | libraries = gl_libs, |
1e7ecb7b RD |
945 | |
946 | extra_compile_args = cflags, | |
f32afe1c | 947 | extra_link_args = gl_lflags, |
1e7ecb7b RD |
948 | ) |
949 | ||
950 | wxpExtensions.append(ext) | |
c368d904 RD |
951 | |
952 | ||
953 | #---------------------------------------------------------------------- | |
954 | # Define the OGL extension module | |
955 | #---------------------------------------------------------------------- | |
956 | ||
1e4a197e | 957 | if BUILD_OGL: |
cfe766c3 | 958 | msg('Preparing OGL...') |
c368d904 | 959 | location = 'contrib/ogl' |
c368d904 | 960 | |
a32360e0 | 961 | swig_sources = run_swig(['ogl.i'], location, GENDIR, PKGDIR, |
d14a1e28 RD |
962 | USE_SWIG, swig_force, swig_args, swig_deps + |
963 | [ '%s/_oglbasic.i' % location, | |
964 | '%s/_oglshapes.i' % location, | |
965 | '%s/_oglshapes2.i' % location, | |
966 | '%s/_oglcanvas.i' % location, | |
967 | '%s/_ogldefs.i' % location, | |
968 | ]) | |
c368d904 | 969 | |
d14a1e28 | 970 | ext = Extension('_ogl', |
3ef86e32 | 971 | swig_sources, |
1e7ecb7b | 972 | |
a32360e0 | 973 | include_dirs = includes + [ location ], |
dd116e73 | 974 | define_macros = defines + [('wxUSE_DEPRECATED', '0')], |
1e7ecb7b RD |
975 | |
976 | library_dirs = libdirs, | |
3ef86e32 | 977 | libraries = libs + makeLibName('ogl'), |
1e7ecb7b RD |
978 | |
979 | extra_compile_args = cflags, | |
980 | extra_link_args = lflags, | |
981 | ) | |
982 | ||
983 | wxpExtensions.append(ext) | |
984 | ||
985 | ||
c368d904 RD |
986 | |
987 | #---------------------------------------------------------------------- | |
988 | # Define the STC extension module | |
989 | #---------------------------------------------------------------------- | |
990 | ||
1e4a197e | 991 | if BUILD_STC: |
cfe766c3 | 992 | msg('Preparing STC...') |
c368d904 | 993 | location = 'contrib/stc' |
5a2a9da2 RD |
994 | if os.name == 'nt': |
995 | STC_H = opj(WXDIR, 'contrib', 'include/wx/stc') | |
996 | else: | |
997 | STC_H = opj(WXPREFIX, 'include/wx/stc') | |
55c020cf | 998 | |
de7b7fe6 | 999 | ## NOTE: need to add something like this to the stc.bkl... |
55c020cf | 1000 | |
3ef86e32 RD |
1001 | ## # Check if gen_iface needs to be run for the wxSTC sources |
1002 | ## if (newer(opj(CTRB_SRC, 'stc/stc.h.in'), opj(CTRB_INC, 'stc/stc.h' )) or | |
1003 | ## newer(opj(CTRB_SRC, 'stc/stc.cpp.in'), opj(CTRB_SRC, 'stc/stc.cpp')) or | |
1004 | ## newer(opj(CTRB_SRC, 'stc/gen_iface.py'), opj(CTRB_SRC, 'stc/stc.cpp'))): | |
55c020cf | 1005 | |
3ef86e32 RD |
1006 | ## msg('Running gen_iface.py, regenerating stc.h and stc.cpp...') |
1007 | ## cwd = os.getcwd() | |
1008 | ## os.chdir(opj(CTRB_SRC, 'stc')) | |
1009 | ## sys.path.insert(0, os.curdir) | |
1010 | ## import gen_iface | |
1011 | ## gen_iface.main([]) | |
1012 | ## os.chdir(cwd) | |
c368d904 RD |
1013 | |
1014 | ||
d14a1e28 | 1015 | swig_sources = run_swig(['stc.i'], location, '', PKGDIR, |
c368d904 RD |
1016 | USE_SWIG, swig_force, |
1017 | swig_args + ['-I'+STC_H, '-I'+location], | |
10ef30eb | 1018 | [opj(STC_H, 'stc.h')] + swig_deps) |
c368d904 | 1019 | |
d14a1e28 | 1020 | ext = Extension('_stc', |
3ef86e32 RD |
1021 | swig_sources, |
1022 | ||
1023 | include_dirs = includes, | |
1024 | define_macros = defines, | |
1e7ecb7b RD |
1025 | |
1026 | library_dirs = libdirs, | |
3ef86e32 | 1027 | libraries = libs + makeLibName('stc'), |
c368d904 | 1028 | |
1e7ecb7b RD |
1029 | extra_compile_args = cflags, |
1030 | extra_link_args = lflags, | |
1031 | ) | |
1032 | ||
1033 | wxpExtensions.append(ext) | |
c368d904 RD |
1034 | |
1035 | ||
1036 | ||
926bb76c RD |
1037 | #---------------------------------------------------------------------- |
1038 | # Define the IEWIN extension module (experimental) | |
1039 | #---------------------------------------------------------------------- | |
1040 | ||
1e4a197e | 1041 | if BUILD_IEWIN: |
cfe766c3 | 1042 | msg('Preparing IEWIN...') |
926bb76c RD |
1043 | location = 'contrib/iewin' |
1044 | ||
1045 | swig_files = ['iewin.i', ] | |
1046 | ||
1047 | swig_sources = run_swig(swig_files, location, '', PKGDIR, | |
10ef30eb | 1048 | USE_SWIG, swig_force, swig_args, swig_deps) |
926bb76c RD |
1049 | |
1050 | ||
de7b7fe6 | 1051 | ext = Extension('_iewin', ['%s/IEHtmlWin.cpp' % location, |
c731eb47 | 1052 | '%s/wxactivex.cpp' % location, |
926bb76c RD |
1053 | ] + swig_sources, |
1054 | ||
1055 | include_dirs = includes, | |
1056 | define_macros = defines, | |
1057 | ||
1058 | library_dirs = libdirs, | |
1059 | libraries = libs, | |
1060 | ||
1061 | extra_compile_args = cflags, | |
1062 | extra_link_args = lflags, | |
1063 | ) | |
1064 | ||
1065 | wxpExtensions.append(ext) | |
1066 | ||
1067 | ||
d56cebe7 RD |
1068 | #---------------------------------------------------------------------- |
1069 | # Define the XRC extension module | |
1070 | #---------------------------------------------------------------------- | |
1071 | ||
1e4a197e | 1072 | if BUILD_XRC: |
cfe766c3 | 1073 | msg('Preparing XRC...') |
d56cebe7 | 1074 | location = 'contrib/xrc' |
d56cebe7 | 1075 | |
d14a1e28 RD |
1076 | swig_sources = run_swig(['xrc.i'], location, '', PKGDIR, |
1077 | USE_SWIG, swig_force, swig_args, swig_deps + | |
1078 | [ '%s/_xrc_rename.i' % location, | |
1079 | '%s/_xrc_ex.py' % location, | |
1080 | '%s/_xmlres.i' % location, | |
1081 | '%s/_xmlsub.i' % location, | |
1082 | '%s/_xml.i' % location, | |
1083 | '%s/_xmlhandler.i' % location, | |
1084 | ]) | |
1085 | ||
1086 | ext = Extension('_xrc', | |
3ef86e32 | 1087 | swig_sources, |
1fded56b | 1088 | |
3ef86e32 | 1089 | include_dirs = includes, |
d56cebe7 RD |
1090 | define_macros = defines, |
1091 | ||
1092 | library_dirs = libdirs, | |
3ef86e32 | 1093 | libraries = libs + makeLibName('xrc'), |
d56cebe7 RD |
1094 | |
1095 | extra_compile_args = cflags, | |
1096 | extra_link_args = lflags, | |
1097 | ) | |
1098 | ||
1099 | wxpExtensions.append(ext) | |
1100 | ||
1101 | ||
1102 | ||
ebf4302c RD |
1103 | #---------------------------------------------------------------------- |
1104 | # Define the GIZMOS extension module | |
1105 | #---------------------------------------------------------------------- | |
1106 | ||
1e4a197e | 1107 | if BUILD_GIZMOS: |
ebf4302c RD |
1108 | msg('Preparing GIZMOS...') |
1109 | location = 'contrib/gizmos' | |
ebf4302c | 1110 | |
a32360e0 | 1111 | swig_sources = run_swig(['gizmos.i'], location, GENDIR, PKGDIR, |
10ef30eb | 1112 | USE_SWIG, swig_force, swig_args, swig_deps) |
ebf4302c | 1113 | |
d14a1e28 | 1114 | ext = Extension('_gizmos', |
d84a9306 | 1115 | [ '%s/treelistctrl.cpp' % location ] + swig_sources, |
ebf4302c | 1116 | |
a32360e0 | 1117 | include_dirs = includes + [ location ], |
ebf4302c RD |
1118 | define_macros = defines, |
1119 | ||
1120 | library_dirs = libdirs, | |
3ef86e32 | 1121 | libraries = libs + makeLibName('gizmos'), |
ebf4302c RD |
1122 | |
1123 | extra_compile_args = cflags, | |
1124 | extra_link_args = lflags, | |
1125 | ) | |
1126 | ||
1127 | wxpExtensions.append(ext) | |
1128 | ||
1129 | ||
1130 | ||
4a61305d RD |
1131 | #---------------------------------------------------------------------- |
1132 | # Define the DLLWIDGET extension module | |
1133 | #---------------------------------------------------------------------- | |
1134 | ||
1e4a197e | 1135 | if BUILD_DLLWIDGET: |
4a61305d RD |
1136 | msg('Preparing DLLWIDGET...') |
1137 | location = 'contrib/dllwidget' | |
1138 | swig_files = ['dllwidget_.i'] | |
1139 | ||
1140 | swig_sources = run_swig(swig_files, location, '', PKGDIR, | |
10ef30eb | 1141 | USE_SWIG, swig_force, swig_args, swig_deps) |
4a61305d RD |
1142 | |
1143 | # copy a contrib project specific py module to the main package dir | |
1144 | copy_file(opj(location, 'dllwidget.py'), PKGDIR, update=1, verbose=0) | |
1145 | ||
1146 | ext = Extension('dllwidget_c', [ | |
1147 | '%s/dllwidget.cpp' % location, | |
1148 | ] + swig_sources, | |
1149 | ||
1150 | include_dirs = includes, | |
1151 | define_macros = defines, | |
1152 | ||
1153 | library_dirs = libdirs, | |
1154 | libraries = libs, | |
1155 | ||
1156 | extra_compile_args = cflags, | |
1157 | extra_link_args = lflags, | |
1158 | ) | |
1159 | ||
1160 | wxpExtensions.append(ext) | |
1161 | ||
1162 | ||
1e4a197e RD |
1163 | |
1164 | ||
1165 | #---------------------------------------------------------------------- | |
1166 | # Tools and scripts | |
1167 | #---------------------------------------------------------------------- | |
8916d007 | 1168 | |
2eb31f8b RD |
1169 | if NO_SCRIPTS: |
1170 | SCRIPTS = None | |
1171 | else: | |
1e4a197e RD |
1172 | SCRIPTS = [opj('scripts/helpviewer'), |
1173 | opj('scripts/img2png'), | |
2eb31f8b RD |
1174 | opj('scripts/img2xpm'), |
1175 | opj('scripts/img2py'), | |
1176 | opj('scripts/xrced'), | |
1177 | opj('scripts/pyshell'), | |
1178 | opj('scripts/pycrust'), | |
1fded56b RD |
1179 | opj('scripts/pywrap'), |
1180 | opj('scripts/pywrap'), | |
1181 | opj('scripts/pyalacarte'), | |
1182 | opj('scripts/pyalamode'), | |
2eb31f8b | 1183 | ] |
4a61305d | 1184 | |
926bb76c | 1185 | |
c2079460 RD |
1186 | DATA_FILES += find_data_files('wx/tools/XRCed', '*.txt', '*.xrc') |
1187 | DATA_FILES += find_data_files('wx/py', '*.txt', '*.ico', '*.css', '*.html') | |
1fded56b | 1188 | DATA_FILES += find_data_files('wx', '*.txt', '*.css', '*.html') |
1e4a197e RD |
1189 | |
1190 | ||
c368d904 RD |
1191 | #---------------------------------------------------------------------- |
1192 | # Do the Setup/Build/Install/Whatever | |
1193 | #---------------------------------------------------------------------- | |
1194 | ||
1b62f00d | 1195 | if __name__ == "__main__": |
1e4a197e | 1196 | if not PREP_ONLY: |
d14a1e28 | 1197 | setup(name = 'wxPython', |
1b62f00d RD |
1198 | version = VERSION, |
1199 | description = DESCRIPTION, | |
1200 | long_description = LONG_DESCRIPTION, | |
1201 | author = AUTHOR, | |
1202 | author_email = AUTHOR_EMAIL, | |
1203 | url = URL, | |
851d4ac7 | 1204 | download_url = DOWNLOAD_URL, |
e2e02194 | 1205 | license = LICENSE, |
851d4ac7 RD |
1206 | platforms = PLATFORMS, |
1207 | classifiers = filter(None, CLASSIFIERS.split("\n")), | |
1208 | keywords = KEYWORDS, | |
d14a1e28 | 1209 | |
1fded56b RD |
1210 | packages = ['wxPython', |
1211 | 'wxPython.lib', | |
1212 | 'wxPython.lib.colourchooser', | |
1213 | 'wxPython.lib.editor', | |
1214 | 'wxPython.lib.mixins', | |
1fded56b | 1215 | 'wxPython.tools', |
1fded56b RD |
1216 | |
1217 | 'wx', | |
1218 | 'wx.lib', | |
1219 | 'wx.lib.colourchooser', | |
1220 | 'wx.lib.editor', | |
1221 | 'wx.lib.mixins', | |
1222 | 'wx.py', | |
d14a1e28 | 1223 | 'wx.py.wxd', |
1fded56b RD |
1224 | 'wx.tools', |
1225 | 'wx.tools.XRCed', | |
1b62f00d RD |
1226 | ], |
1227 | ||
1228 | ext_package = PKGDIR, | |
1229 | ext_modules = wxpExtensions, | |
8916d007 | 1230 | |
f6f98ecc | 1231 | options = { 'build' : { 'build_base' : BUILD_BASE }}, |
a541c325 | 1232 | |
b817523b | 1233 | scripts = SCRIPTS, |
c368d904 | 1234 | |
1e4a197e RD |
1235 | cmdclass = { 'install_data': smart_install_data}, |
1236 | data_files = DATA_FILES, | |
8916d007 | 1237 | |
1b62f00d | 1238 | ) |
c368d904 | 1239 | |
c368d904 | 1240 | |
c368d904 RD |
1241 | #---------------------------------------------------------------------- |
1242 | #---------------------------------------------------------------------- |