]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/distrib/make_static_setup.py
2 #---------------------------------------------------------------------------
3 # This script generates a template that can be used in the Python
4 # build process (on posix systems) in order to staticly link the
5 # wxPython modules into the Python executable. The output of this
6 # script should be put into a file named Setup.local (or perhaps just
7 # concatenated to Setup) in the Modules dir of the Python source
8 # distribution, then just build Python like normal.
10 # You can use any of the command-line args that setup.py understands
11 # with this script too in order to control what modules are built and
12 # which compile options and such are used.
14 # This script must be run from the wxPython directory.
15 #---------------------------------------------------------------------------
20 # if you need to change some setup.py flags do it here before it is
21 # imported. Just append to sys.argv.
22 sys
.argv
.append("BUILD_GLCANVAS=0")
23 sys
.argv
.append("BUILD_OGL=0")
24 sys
.argv
.append("BUILD_DLLWIDGET=0")
25 #sys.argv.append("CORE_ONLY=1")
35 def buildflags(items
, flag
, path
=None):
38 if path
is not None and item
[0] != '/':
39 item
= os
.path
.join(path
, item
)
40 st
+= "%s%s " % (flag
, item
)
44 def buildmacros(items
):
48 st
+= "-U%s " % item
[0]
50 st
+= "-D%s " % item
[0]
52 st
+= "-D%s=%s " % item
56 # Python's makesetup can't handle -D flags with = in them, so we need to workaround
59 pat
= re
.compile(r
'-D([A-Za-z0-9_]*)=([A-Za-z0-9_]*)')
60 match
= pat
.search(st
)
61 while match
is not None:
63 value
= match
.group(2)
64 defs
.append("m_%s = -D%s=%s" % (name
, name
, value
))
65 st
= st
[:match
.start()] + ("$(m_%s)" % name
) + st
[match
.end():]
66 match
= pat
.search(st
)
76 # This file is autogenerated by %s and should be
77 # placed in the <PythonDist>/Modules/Setup.local file before
84 for ext
in setup
.wxpExtensions
:
85 eca
= " ".join(ext
.extra_compile_args
)
86 macros
= buildmacros(ext
.define_macros
)
88 eca
, defs
= fixmacros(eca
)
90 macros
, defs
= fixmacros(macros
)
95 printitem(os
.path
.join(cwd
, s
))
96 printitem(buildflags(ext
.include_dirs
, '-I', cwd
))
97 printitem(buildflags(ext
.library_dirs
, '-L'))
98 printitem(buildflags(ext
.libraries
, '-l'))
101 # filter out some options that makesetup can't handle, but it shouldn't hurt to remove these...
102 ela
= filter(lambda x
: x
not in ['-pthread', '-rdynamic'], ext
.extra_link_args
)
103 printitem(" ".join(ela
))
109 if __name__
== "__main__":