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