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