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