]> git.saurik.com Git - wxWidgets.git/blob - wxPython/BUILD.win32.txt
0687e8d53dbed36efbd20a8e0e645db9d0838db4
[wxWidgets.git] / wxPython / BUILD.win32.txt
1 Building wxPython on Win32
2 --------------------------
3
4
5 Building wxPython for use on win32 systems is a fairly simple process
6 consisting of just a few steps. However depending on where you get
7 your sources from and what your desired end result is, there are
8 several permutations of those steps. At a high level the basic steps
9 are:
10
11 1. Get the wxWindows sources
12 2. Build the wxWindows DLL
13 3. Get the wxPython sources
14 4. Build and Install wxPython
15
16 We'll go into more detail of each of these steps below, but first a
17 few bits of background information on tools.
18
19 I use a tool called SWIG (http://www.swig.org) to help generate the
20 C++ sources used in the wxPython extension module. However you don't
21 need to have SWIG unless you want to modify the *.i files. I've made
22 several modifications to SWIG specific to wxPython's needs and so the
23 modified sources are included in the wx CVS at .../wxPython/wxSWIG.
24 If you need to modify the *.i files for wxPython then change to this
25 directory and run:
26
27 nmake -f makefile.vc
28
29 Then you'll need to change a flag in the setup.py script as described
30 below so the wxPython build process will use SWIG if needed.
31
32 I use the new Python Distutils tool to build wxPython. It is included
33 with Python 2.0, but if you want to use Python 1.5.2 or 1.6 then
34 you'll need to download and install Distutils 1.0 from
35 http://www.python.org/sigs/distutils-sig/
36
37 I use Microsoft Visual C++ 6.0 (5.0 with the service packs should work
38 also) to compile the wxPython C++ sources. Since I am using Distutils
39 it should be easier now to build with other win32 compilers such as
40 the free mingw32 or Borland compilers, but I havn't tried them yet.
41 If anybody wants to try it I'll take any required patches for the
42 setup script and for these instructions.
43
44 And now on to the fun stuff...
45
46
47
48 1. Get the wxWindows sources
49 ----------------------------
50
51 A. There are a few possible ways to get sources for wxWindows. You
52 can download a released version from http://wxwindows.org/ or you
53 can get current development sources from the CVS server. (Some
54 information about annonymous CVS access is at the
55 http://wxwindows.org/cvs.htm site.) The advantage of using CVS is
56 that you can easily update as soon as the developers check in new
57 sources or fixes. The advantage of using a released version is
58 that it usually has had more thorough testing done. You can decide
59 which method is best for you.
60
61 B. You'll usually want to use wxWindows sources that have the same
62 version number as the wxPython sources you are using. (Another
63 advantage of using CVS is that you'll get both at the same time.)
64
65 C. Once you get the sources be sure to put them in a path without a
66 space in it (i.e., NOT c:\Program Files\wx) and set an environment
67 variable named WXWIN to this directory. For example:
68
69 mkdir \wx2
70 cd \wx2
71 unzip wxMSW-2.2.2.zip
72 set WXWIN=c:\wx2
73
74 You'll probably want to add that last line to your autoexec.bat or
75 System Properties depending on the type of system you are on.
76
77 D. Change to the wx2\include\wx\msw directory and copy setup0.h to
78 setup.h and then edit setup.h. This is how you control which parts
79 of wxWindows are compiled into or left out of the build, simply by
80 turning options on or off. I have the following differences from
81 the default setup0.h in my setup.h, but you can experiment with
82 other settings if you like:
83
84 WXWIN_COMPATIBILITY_2_2 0
85 wxDIALOG_UNIT_COMPATIBILITY 0
86 wxUSE_MEMORY_TRACING 1
87 wxUSE_CMDLINE_PARSER 0
88 wxUSE_FSVOLUME 0
89 wxUSE_DIALUP_MANAGER 0
90 wxUSE_TREELAYOUT 0
91 wxUSE_POSTSCRIPT 1
92
93
94 ** NEW **
95 Be sure that wxUSE_GLCANVAS is defined to be 0 as wxPython now
96 keeps its own copy of the glcanvas sources and expects that it is
97 not in the main library. This is done to reduce the number of
98 dependant DLLs on the core library and therefore help reduce
99 startup time.
100
101
102
103 2. Build the wxWindows DLL
104 ---------------------------
105
106 A. Although MSVC project files are provided I always use the makefiles
107 to build wxWindows because by default the flags are compatible with
108 Python, (and I make sure they stay that way.) You would have to
109 edit the project files a bit to make it work otherwise.
110
111 B. There are three different types of wxWindows DLLs that can be
112 produced by the VC makefile simply by providing a flag on the nmake
113 command-line, I call the three types DEBUG, FINAL, and HYBRID.
114 Here are some more details:
115
116 DEBUG Specified with "FINAL=0" and produces a DLL named
117 wxmsw[version]d.dll. This DLL is compiled with full
118 debugging information and with the __WXDEBUG__ macro set,
119 which enables some debugging-only code in wxWindows such
120 as assertions and failure log messages. The /MDd flag is
121 used which means that it is linked with the debugging
122 version of the C runtime library and also that you must
123 use the debugging version of Python, (python_d.exe and
124 pythonXX_d.dll) which also means that all extensions
125 loaded by Python should also have the _d in the name.
126 With this option you can use the MSVC debugger to trace
127 though the Python interpreter, as well as the code for the
128 wxPython extension and the wxWindows DLL.
129
130 FINAL Specified with "FINAL=1" and produces a DLL named
131 wxmsw[version].dll. This DLL is compiled with optimizations
132 turned on and without debugging information and without
133 __WXDEBUG__. The /MD flag is used which means that you
134 can use this version with the standard python.exe. This
135 is the version that I use when making the binary installer
136 for win32.
137
138 HYBRID Specified with "FINAL=hybrid" and produces a DLL named
139 wxmsw[version]h.dll. This DLL is almost the same as the
140 DEBUG version except the /MD flag is used which means that
141 you can use the standard python.exe but you still get the
142 debugging info and the __WXDEBUG__ code enabled. With the
143 debugger you can trace through the the code for the
144 wxPython extension and the wxWindows DLL, but not the
145 Python interpreter. You might use this version when you
146 want to deploy a wxPython app with the __WXDEBUG__ code
147 enabled. I use this mode most of the time during
148 development simply because it's easier than having to
149 remember to type python_d all the time.
150
151 Since different DLL names and object file directories are used you
152 can build all three types if you like.
153
154 C. Change to the wx2\src\msw directory and type the following command,
155 using the value for FINAL that you want:
156
157 nmake -f makefile.vc dll pch FINAL=hybrid
158
159 Your machine will then crunch away for possibly a long time,
160 depending on your hardware, and when it's done you should have a
161 DLL and some library files in \wx2\lib.
162
163 D. You'll either need to add \wx2\lib to the PATH or copy the DLL file
164 to a directory already on the PATH so the DLL can be found at
165 runtime. Another option is to copy the DLL to the directory that
166 the wxPython pacakge is installed to, for example,
167 c:\Python22\lib\site-packages\wxPython.
168
169 E. You can test your build by changing to one of the directories under
170 \wx2\samples or \wx2\demos and typing (using the right FINAL flag):
171
172 nmake -f makefile.vc FINAL=hybrid WXUSINGDLL=1
173
174 and then executing the resulting .exe file.
175
176
177
178 3. Get the wxPython sources
179 ---------------------------
180
181 A. You have the same options (and same advantages/disadvantages) for
182 getting the wxPython source, either a released snapshot or from
183 CVS. The released version file is named wxPython-[version].tar.gz
184 and is available at http://wxpython.org/download.php. You can use
185 WinZip to unpack it if you don't have tar and gzip. If you want to
186 use CVS you'll find wxPython in the wxWindows CVS tree (see above)
187 in the wxWindows/wxPython directory.
188
189
190
191 4. Build and Install wxPython
192 -----------------------------
193
194 A. As mentioned previouslly, wxPython is built with the standard
195 Python Distutils tool. If you are using Python 2.0 or later you
196 are all set, otherwise you need to download and install Distutils
197 1.0 from http://www.python.org/sigs/distutils-sig/.
198
199 B. Change to the root wxPython directory and look at the setup.py
200 file. This is the script that configures and defines all the
201 information that Distutils needs to build wxPython. There are some
202 options near the begining of the script that you may want or need
203 to change based on what options you have selected up to this point,
204 (type of DLL built, sources from tar.gz or from CVS, etc.) You can
205 either change these flags directly in setup.py or supply them on
206 the command-line.
207
208 BUILD_GLCANVAS Set to zero if you don't want to build the
209 Open GL canvas extension module.
210
211 BUILD_OGL Set to zero if you don't want to build the
212 Object Graphics Library extension module.
213
214 BUILD_STC Set to zero if you don't want to build the
215 wxStyledTextCtrl (the Scintilla wrapper)
216 extension module.
217
218 USE_SWIG If you have edited any of the *.i files you
219 will need to set this flag to non-zero so SWIG
220 will be executed to regenerate the wrapper C++
221 and shadow python files.
222
223 IN_CVS_TREE If you are using the CVS version of the
224 wxWindows and wxPython sources then you will
225 need to set this flag to non-zero. This is
226 needed because some source files from the
227 wxWindows tree are copied to be under the
228 wxPython tree in order to keep Distutils happy.
229 With this flag set then setup.py will
230 automatically keep these copied sources up to
231 date if the original version is ever updated.
232 If you are using the tar.gz version of the
233 Python sources then these copied sources are
234 already present in your source tree.
235
236
237 C. To build and install wxPython you simply need to execute the
238 setup.py script. If you have more than one version of Python
239 installed, be sure to execute setup.py with the version you want to
240 build wxPython for.
241
242 Depending on what kind of wxWindows DLL you built there are
243 different command-line parameters you'll want to pass to setup (in
244 addition to possibly one or more of the above):
245
246 FINAL: python setup.py install
247
248 DEBUG: python setup.py build --debug install
249
250 HYBRID: python setup.py HYBRID=1 install
251
252 NOTE: If you get an internal compiler error from MSVC then you
253 need to edit setup.py and add in the /GX- flag that is normally
254 commented out. Just search for "GX-" and uncomment it so it is put
255 into the cflags list.
256
257
258 D. At this point you should be able to change into the wxPython\demo
259 directory and run the demo:
260
261 python demo.py
262
263 E. If you would like to make a test build that doesn't overwrite the
264 installed version of wxPython you can do so with one of these
265 commands instead of the install command above:
266
267 FINAL: python setup.py build_ext --inplace
268
269 DEBUG: python setup.py build_ext --debug --inplace
270
271 HYBRID: python setup.py HYBRID=1 build_ext --inplace
272
273 This will build the wxPython package in the local wxPython
274 directory instead of installing it under your Python installation.
275 To run using this test version just add the base wxPython source
276 directory to the PYTHONPATH:
277
278 set PYTHONPATH=c:\wx2\wxPython
279 cd c:\wx2\wxPython\demo
280 python demo.py
281
282
283 That's all folks!
284
285
286 -----------------
287 robin@alldunn.com
288