]> git.saurik.com Git - wxWidgets.git/blame - wxPython/docs/BUILD.html
typo
[wxWidgets.git] / wxPython / docs / BUILD.html
CommitLineData
8eda5e35
RD
1<?xml version="1.0" encoding="iso-8859-1" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
6<meta name="generator" content="Docutils 0.3.1: http://docutils.sourceforge.net/" />
7<title>Building wxPython 2.5 for Development and Testing</title>
8<link rel="stylesheet" href="default.css" type="text/css" />
9</head>
10<body>
11<div class="document" id="building-wxpython-2-5-for-development-and-testing">
12<h1 class="title">Building wxPython 2.5 for Development and Testing</h1>
fc33e5e1 13<p>This file describes how I build wxWidgets and wxPython while doing
8eda5e35
RD
14development and testing, and is meant to help other people that want
15to do the same thing. I'll assume that you are using either a CVS
fc33e5e1 16snapshot from <a class="reference" href="http://wxWidgets.org/snapshots/">http://wxWidgets.org/snapshots/</a>, a checkout from CVS, or
8eda5e35 17one of the released wxPythonSrc-2.5.* tarballs. I'll also assume that
9c329f86
RD
18you know your way around your system, the compiler, etc. and most
19importantly, that you know what you are doing! ;-)</p>
8eda5e35
RD
20<p>If you want to also install the version of wxPython you build to be in
21your site-packages dir and be your default version of wxPython, then a
22few additional steps are needed, and you may want to use slightly
23different options. See INSTALL.txt for more details. If you only use
24the instructions in this BUILD.txt file then you will end up with a
25separate installation of wxPython and you can switch back and forth
26between this and the release version that you may already have
27installed.</p>
28<p>If you want to make changes to any of the <tt class="literal"><span class="pre">*.i</span></tt> files, (SWIG interface
29definition files,) or to regenerate the extension sources or renamer
30modules, then you will need an up to date version of SWIG. Either get
31and build the current CVS version, or version 1.3.20, and then apply
32the patches in wxPython/SWIG. See the README.txt in that dir for
33details about each patch and also info about those that may already
34have been applied to the SWIG sources. If you install this build of
35SWIG to a location that is not on the PATH (so it doesn't interfere
36with an existing SWIG install for example) then you can set a setup.py
37command-line variable named SWIG to be the full path name of the
38executable and the wxPython build will use it. See below for an
39example.</p>
40<div class="section" id="building-on-unix-like-systems-e-g-linux-and-os-x">
41<h1><a name="building-on-unix-like-systems-e-g-linux-and-os-x">Building on Unix-like Systems (e.g. Linux and OS X)</a></h1>
42<p>These platforms are built almost the same way while in development
43so I'll combine the descriptions about their build process here.
fc33e5e1 44First we will build wxWidgets and install it to an out of the way
8eda5e35
RD
45place, then do the same for wxPython.</p>
46<ol class="arabic">
fc33e5e1
RD
47<li><p class="first">Create a build directory in the main wxWidgets dir, and configure
48wxWidgets. If you want to have multiple builds with different
8eda5e35
RD
49configure options, just use different subdirectories. I normally
50put the configure command in a script named &quot;.configure&quot; in each
51build dir so I can easily blow away everything in the build dir and
52rerun the script without having to remember the options I used
53before:</p>
54<pre class="literal-block">
55mkdir bld
56cd bld
57../configure --prefix=/opt/wx/2.5 \
58 --with-gtk \
59 --with-opengl \
60 --disable-monolithic \
61 --enable-debug \
62 --enable-geometry \
fc33e5e1
RD
63 --enable-sound --with-sdl \
64 --enable-display \
8eda5e35
RD
65</pre>
66<p>On OS X of course you'll want to use --with-mac instead of
67--with-gtk. For GTK2 and unicode add:</p>
fc33e5e1
RD
68<pre class="literal-block">
69--enable-gtk2 \
70--enable-unicode \
71</pre>
8eda5e35
RD
72<p>Notice that I used a prefix of /opt/wx/2.5. You can use whatever
73path you want, such as a path in your HOME dir or even one of the
74standard prefix paths such as /usr or /usr/local if you like, but
75using /opt this way lets me easily have multiple versions and ports
fc33e5e1
RD
76of wxWidgets &quot;installed&quot; and makes it easy to switch between them,
77without impacting any versions of wxWidgets that may have been
8eda5e35
RD
78installed via an RPM or whatever. For the rest of the steps below
79be sure to also substitute &quot;/opt/wx/2.5&quot; with whatever prefix you
80choose for your build.</p>
81<p>If you want to use the image and zlib libraries included with
fc33e5e1 82wxWidgets instead of those already installed on your system, (for
8eda5e35
RD
83example, to reduce dependencies on 3rd party libraries) then you
84can add these flags to the configure command:</p>
85<pre class="literal-block">
86--with-libjpeg=builtin \
87--with-libpng=builtin \
88--with-libtiff=builtin \
89--with-zlib=builtin \
90</pre>
91</li>
fc33e5e1
RD
92<li><p class="first">To build and install wxWidgets you could just use the &quot;make&quot;
93command but there are other libraries besides the main wxWidgets
8eda5e35
RD
94libs that also need to be built so again I make a script to do it
95all for me so I don't forget anything. This time it is called
96&quot;.make&quot; (I use the leading &quot;. so when I do <tt class="literal"><span class="pre">rm</span> <span class="pre">-r</span> <span class="pre">*</span></tt> in my build
97dir I don't lose my scripts too.) This is what it looks like:</p>
98<pre class="literal-block">
99make $* \
100 &amp;&amp; make -C contrib/src/gizmos $* \
101 &amp;&amp; make -C contrib/src/ogl CXXFLAGS=&quot;-DwxUSE_DEPRECATED=0&quot; $* \
102 &amp;&amp; make -C contrib/src/stc $* \
103 &amp;&amp; make -C contrib/src/xrc $*
104</pre>
105<p>So you just use .make as if it where make, but don't forget to set
106the execute bit on .make first!:</p>
107<pre class="literal-block">
108.make
109.make install
110</pre>
111<p>When it's done you should have an installed set of files under
fc33e5e1
RD
112/opt/wx/2.5 containing just wxWidgets. Now to use this version of
113wxWidgets you just need to add /opt/wx/2.5/bin to the PATH and set
8eda5e35
RD
114LD_LIBRARY_PATH (or DYLD_LIBRARY_PATH on OS X) to /opt/wx/2.5/lib.</p>
115</li>
116<li><p class="first">I also have a script to help me build wxPython and it is checked in
fc33e5e1 117to the CVS as wxWidgets/wxPython/b, but probably don't want to use
8eda5e35
RD
118it as it's very cryptic and expects that you want to run SWIG, so
119if you don't have the latest patched up version of SWIG then you'll
120probably get stuck. So I'll just give the raw commands instead.</p>
121<p>We're not going to install the development version of wxPython with
122these commands, so it won't impact your already installed version
123of the latest release. You'll be able test with this version when
124you want to, and use the installed release version the rest of the
125time. If do want to install the development verison please read
126INSTALL.txt.</p>
127<p>If you have more than one version of Python on your system then be
128sure to use the version of Python that you want to use when running
129wxPython programs to run the setup.py commands below. I'll be
130using python2.3.</p>
131<p>Make sure that the first wx-config found on the PATH is the one you
fc33e5e1 132installed above, and then change to the wxWidgets/wxPython dir and
8eda5e35
RD
133run the this command:</p>
134<pre class="literal-block">
135cd wxPython
136python2.3 setup.py build_ext --inplace --debug
137</pre>
138<p>If your new wx-config script is not on the PATH, or there is some
139other version of it found first, then you can add this to the
140command line to ensure your new one is used instead:</p>
141<pre class="literal-block">
142WX_CONFIG=/opt/wx/2.5/bin/wx-config
143</pre>
144<p>If you are building with GTK2 then add the following flags to the
145command line:</p>
146<pre class="literal-block">
147WXPORT=gtk2 UNICODE=1
148</pre>
149<p>If you are wanting to have the source files regenerated with swig,
150then you need to turn on the USE_SWIG flag and optionally tell it
151where to find the new swig executable, so add these flags:</p>
152<pre class="literal-block">
153USE_SWIG=1 SWIG=/opt/swig/bin/swig
154</pre>
155<p>If you get errors about wxGLCanvas or being unable to find libGLU
156or something like that then you can add BUILD_GLCANVAS=0 to the
157setup.py command line to disable the building of the glcanvas
158module.</p>
159<p>When the setup.py command is done you should have fully populated
fc33e5e1 160wxPython and wx packages locally in wxWidgets/wxPython/wxPython and
8eda5e35
RD
161.../wx, with all the extension modules (<tt class="literal"><span class="pre">*.so</span></tt> files) located in the
162wx package.</p>
163</li>
164<li><p class="first">To run code with the development verison of wxPython, just set the
165PYTHONPATH to the wxPython dir in the CVS tree. For example:</p>
166<pre class="literal-block">
167export LD_LIBRARY=/opt/wx/2.5/lib
fc33e5e1
RD
168export PYTHONPATH=/myprojects/wxWidgets/wxPython
169cd /myprojects/wxWidgets/wxPython/demo
8eda5e35
RD
170python2.3 demo.py
171</pre>
172<p>OS X NOTE: You need to use &quot;pythonw&quot; on the command line to run
173wxPython applications. This version of the Python executable is
174part of the Python Framework and is allowed to interact with the
9c329f86 175display. You can also double click on a .py or a .pyw file from
8eda5e35
RD
176the finder (assuming that PythonLauncher is still associated with
177these file extensions) and it will launch the Framework version of
178Python for you. For information about creating Applicaiton Bundles
179of your wxPython apps please see the wiki and the mail lists.</p>
180<p>SOLARIS NOTE: If you get unresolved symbol errors when importing
181wxPython and you are running on Solaris and building with gcc, then
182you may be able to work around the problem by uncommenting a bit of
183code in setup.py and building again. Look for 'SunOS' in setup.py
184and uncomment the block containing it. The problem is that Sun's ld
185does not automatically add libgcc to the link step.</p>
186</li>
187</ol>
188</div>
189<div class="section" id="building-on-windows">
190<h1><a name="building-on-windows">Building on Windows</a></h1>
191<p>The Windows builds currently require the use of Microsoft Visual C++.
192Theoretically, other compilers (such as mingw32 or the Borland
193compilers) can also be used but I've never done the work to make that
194happen. If you want to try that then first you'll want to find out if
195there are any tricks that have to be done to make Python extension
196modules using that compiler, and then make a few changes to setup.py
197to accomodate that. (And send the patches to me.) If you plan on
198using VisualStudio.Net (a.k.a. MSVC 7.1) keep in mind that you'll also
199have to build Python and any other extension modules that you use with
200that compiler because a different version of the C runtime likbrary is
201used. The Python executable that comes from PythonLabs and the
202wxPython extensions that I distribute are built with MSVC 6 with all
203the Service Packs applied.</p>
fc33e5e1 204<p>If you want to build a debugable version of wxWidgets and wxPython you
8eda5e35
RD
205will need to have also built a debug version of Python and any other
206extension modules you need to use. You can tell if you have them
207already if there is a _d in the file names, for example python_d.exe
208or python23_d.dll. If you don't need to trace through the C/C++ parts
209of the code with the debugger then building the normal (or hybrid)
210version is fine, and you can use the regular python executables with
211it.</p>
212<p>Just like the unix versions I also use some scripts to help me build
fc33e5e1 213wxWidgets, but I use some non-standard stuff to do it. So if you want
8eda5e35
RD
214to use them too you'll need to get a copy or 4DOS or 4NT from
215<a class="reference" href="http://www.jpsoft.com/">http://www.jpsoft.com/</a> and also a copy of unix-like cat and sed
216programs. You can also do by hand what my scripts are doing, but
217there are a lof steps involved and I won't be going into details
fc33e5e1 218here. There is a copy of my build scripts in wxWidgetswxPythondistribmsw</p>
8eda5e35 219<ol class="arabic">
fc33e5e1 220<li><p class="first">Set an environment variable to the root of the wxWidgets source
8eda5e35
RD
221tree:</p>
222<pre class="literal-block">
fc33e5e1 223set WXWIN=e:\projects\wxWidgets
8eda5e35
RD
224</pre>
225</li>
226<li><p class="first">Copy setup0.h to setup.h</p>
227<blockquote>
228<p>cd %WXWIN%includewxmsw
229copy setup0.h setup.h</p>
230</blockquote>
231</li>
232<li><p class="first">Edit %WXWIN%includewxmswsetup.h and change a few settings.
233Some of them are changed by my build scripts depending on the type
234of build (debug/hybrid, unicode/ansi). I change a few of the other
235defaults to have these values:</p>
236<pre class="literal-block">
237wxDIALOG_UNIT_COMPATIBILITY 0
238wxUSE_DEBUG_CONTEXT 1
239wxUSE_MEMORY_TRACING 1
240wxUSE_DIALUP_MANAGER 0
241wxUSE_GLCANVAS 1
242wxUSE_POSTSCRIPT 1
243wxUSE_AFM_FOR_POSTSCRIPT 0
fc33e5e1 244wxUSE_DISPLAY 1
8eda5e35
RD
245</pre>
246</li>
90805926
RD
247<li><p class="first">Make sure that %WXWIN%libvc_dll directory is on the PATH. The
248wxWidgets DLLs will end up there as part of the build and so you'll
249need it on the PATH for them to be found at runtime.</p>
8eda5e35
RD
250</li>
251<li><p class="first">Change to the %WXWIN%buildmsw directory and copy my build scripts
252there.</p>
253</li>
fc33e5e1 254<li><p class="first">Use the .make.btm command to build wxWidgets. It needs one
8eda5e35
RD
255command-line parameter which controls what kind of build(s) to do.
256Use one of the following:</p>
257<pre class="literal-block">
258debug Build debug version
259hybrid Build hybrid version
260both Both debug and hybrid
261debug-uni Build a debug unicode library
262hybrid-uni Hybrid unicode (see the pattern yet? ;-)
263both-uni and finally both unicode libraries
264</pre>
265<p>For example:</p>
266<pre class="literal-block">
267 .make hybrid
268
269You can also pass additional command line parameters as needed and
270they will all be passed on to the nmake commands, for example to
271clean up the build::
272
273 .make hybrid clean
274</pre>
275</li>
fc33e5e1 276<li><p class="first">When that is done it will have built the main wxWidgets DLLs and
8eda5e35
RD
277also some of the contribs DLLs. There should be a ton of DLLs in
278%WXDIR%bin and lots of lib files and other stuff in
279%WXDIR%libvc_dll.</p>
280</li>
281<li><p class="first">Building wxPython on Windows is very similar to doing it for the
282unix systems. We're not going to install the development version
283of wxPython with these commands, so it won't impact your already
284installed version of the latest release. You'll be able to test
285with this version when you want to, and use the installed release
286version the rest of the time. If you ever do want to install the
287development verison please refer to INSTALL.txt.</p>
fc33e5e1 288<p>Change to the wxWidgetswxPython dir and run the this command,
8eda5e35
RD
289makeing sure that you use the version of python that you want to
290build for (if you have more than one on your system):</p>
291<pre class="literal-block">
292cd %WXWIN%\wxPython
293python setup.py build_ext --inplace
294</pre>
295<p>If you are wanting to have the source files regenerated with swig,
296then you need to turn on the USE_SWIG flag and optionally tell it
297where to find the new swig executable, so add these flags:</p>
298<pre class="literal-block">
299USE_SWIG=1 SWIG=e:\projects\SWIG-cvs\swig.exe
300</pre>
fc33e5e1 301<p>If you built a Unicode version of wxWidgets and want to also build
8eda5e35
RD
302the Unicode version of wxPython then add this flag:</p>
303<pre class="literal-block">
304UNICODE=1
305</pre>
fc33e5e1 306<p>If you have a debug version of Python and wxWidgets and want to
8eda5e35
RD
307build a debug version of wxPython too, add the --debug flag to the
308command line. You should then end up with a set of <tt class="literal"><span class="pre">*_d.pyd</span></tt>
309files in the wx package and you'll have to run <tt class="literal"><span class="pre">python_d.exe</span></tt> to
310use them. The debug and hybrid(release) versions can coexist.</p>
311<p>When the setup.py command is done you should have fully populated
fc33e5e1
RD
312wxPython and wx packages locally in wxWidgets/wxPython/wxPython and
313wxWidgets/wxPython/wx, with all the extension modules (<tt class="literal"><span class="pre">*.pyd</span></tt>
8eda5e35
RD
314files) located in the wx package.</p>
315</li>
316<li><p class="first">To run code with the development verison of wxPython, just set the
317PYTHONPATH to the wxPython dir in the CVS tree. For example:</p>
318<pre class="literal-block">
fc33e5e1
RD
319set PYTHONPATH=e:\projects\wxWidgets\wxPython
320cd e:\projects\wxWidgets\wxPython
8eda5e35
RD
321python demo.py
322</pre>
323</li>
324</ol>
325</div>
326</div>
327<hr class="footer" />
328<div class="footer">
90805926 329Generated on: 2004-03-26 21:09 UTC.
8eda5e35
RD
330</div>
331</body>
332</html>