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