]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh -e | |
2 | #---------------------------------------------------------------------- | |
3 | # Build wxMac and wxPythonOSX from the tarball and then make an | |
4 | # Installer package out of it. | |
5 | ||
6 | spectemplate=distrib/wxPythonFull.spec.in | |
7 | ||
8 | if [ ! -d wxPython -o ! -e ${spectemplate} ]; then | |
9 | echo "Please run this script from the root wxPython directory." | |
10 | exit 1 | |
11 | fi | |
12 | ||
13 | #---------------------------------------------------------------------- | |
14 | # Check Parameters | |
15 | ||
16 | function usage { | |
17 | echo "" | |
18 | echo "Usage: $0 [panther|jaguar] [command flags...]" | |
19 | echo "" | |
20 | echo " panther Build for Apple's python in /usr/bin, such as on Panther" | |
21 | echo " jaguar Build for a python in /usr/local/bin, such as on Jaguar" | |
22 | echo "" | |
23 | echo "optional command flags:" | |
24 | echo " skiptar Don't unpack the tarball" | |
25 | echo " use_cvs Use the CVS workspace instead of a tarfile" | |
26 | echo " skipconfig Don't run configure" | |
27 | echo " skipbuild Don't build wxWidgets or wxPython" | |
28 | echo " skipinstall Don't do the installation step" | |
29 | echo " skipdmg Don't make the package or diskimage" | |
30 | echo " skipclean Don't do the cleanup at the end" | |
31 | echo "" | |
32 | } | |
33 | ||
34 | ||
35 | if [ $# -lt 1 ]; then | |
36 | usage | |
37 | exit 1 | |
38 | fi | |
39 | ||
40 | KIND=$1 | |
41 | case $KIND in | |
42 | panther) PYTHON=/usr/bin/python ;; | |
43 | jaguar) PYTHON=/usr/local/bin/python ;; | |
44 | *) usage; exit 1 ;; | |
45 | esac | |
46 | PYTHONW=${PYTHON}w | |
47 | shift | |
48 | ||
49 | ||
50 | for flag in $*; do | |
51 | case ${flag} in | |
52 | skiptar) skiptar=1 ;; | |
53 | use_cvs) skiptar=1; use_cvs=1 ;; | |
54 | skipconfig) skipconfig=1; skiptar=1 ;; | |
55 | skipbuild) skipbuild=1; skipconfig=1; skiptar=1 ;; | |
56 | skipinstall) skipinstall=1 ;; | |
57 | skipdmg) skipdmg=1 ;; | |
58 | skipclean) skipclean=1 ;; | |
59 | ||
60 | *) echo "Unknown flag \"${flag}\"" | |
61 | usage | |
62 | exit 1 | |
63 | esac | |
64 | done | |
65 | ||
66 | ||
67 | VERSION=`$PYTHON -c "import setup;print setup.VERSION"` | |
68 | PYVER=`$PYTHON -c "import sys; print sys.version[:3]"` | |
69 | PYPREFIX=`$PYTHON -c "import sys; print sys.exec_prefix"` | |
70 | PYLIB=$PYPREFIX/lib/python$PYVER | |
71 | SITEPACKAGES=$PYLIB/site-packages | |
72 | ||
73 | TARBALLDIR=/stuff/Development/wxPython/dist/$VERSION | |
74 | TARBALL=$TARBALLDIR/wxPythonSrc-$VERSION.tar.gz | |
75 | ||
76 | PREFIX=/usr/lib/wxPython-$VERSION | |
77 | BINPREFIX=/usr/bin | |
78 | ||
79 | WXROOT=`dirname $PWD` | |
80 | PROGDIR="`dirname \"$0\"`" | |
81 | TMPDIR=$PWD/_build_dmg | |
82 | ||
83 | BUILDROOT=$TMPDIR/build | |
84 | INSTALLROOT=$TMPDIR/install | |
85 | INSTALLDEVEL=$TMPDIR/install-devel | |
86 | DMGDIR=$TMPDIR/dmg | |
87 | RESOURCEDIR=$PROGDIR/resources | |
88 | DESTDIR=$PWD/dist | |
89 | SRCROOT=$BUILDROOT/wxPythonSrc-$VERSION | |
90 | ||
91 | ||
92 | #---------------------------------------------------------------------- | |
93 | # Setup builddirs | |
94 | ||
95 | mkdir -p $BUILDROOT | |
96 | mkdir -p $INSTALLROOT | |
97 | #mkdir -p $INSTALLDEVEL | |
98 | rm -rf $DMGDIR | |
99 | mkdir -p $DMGDIR/root/Apps | |
100 | mkdir -p $DMGDIR/root/Docs | |
101 | mkdir -p $DMGDIR/root/Samples | |
102 | ||
103 | ||
104 | pushd $BUILDROOT | |
105 | ||
106 | ||
107 | #---------------------------------------------------------------------- | |
108 | # Unpack the tarball | |
109 | ||
110 | if [ -z "$skiptar" ]; then | |
111 | echo Unarchiving tarball... | |
112 | tar xzf $TARBALL | |
113 | fi | |
114 | ||
115 | if [ "$use_cvs" = 1 ]; then | |
116 | # copy the cvs workspace, except for build dirs | |
117 | ||
118 | mkdir -p wxPythonSrc-$VERSION | |
119 | ||
120 | echo Finding updated files... | |
121 | if [ -e .last_copy ]; then | |
122 | FEXPR="-cnewer .last_copy" | |
123 | fi | |
124 | MEASURE=$WXROOT// | |
125 | find $WXROOT $FEXPR -print \ | |
126 | | grep -v $WXROOT/bld \ | |
127 | | grep -v wxPython/build \ | |
128 | | grep -v wxPython/_build \ | |
129 | | grep -v CVS \ | |
130 | | grep -v .pyc \ | |
131 | | cut -b ${#MEASURE}- > filelist | |
132 | ||
133 | for x in `cat filelist`; do | |
134 | if [ -d "$WXROOT/$x" ]; then | |
135 | mkdir -p "wxPythonSrc-$VERSION/$x" | |
136 | else | |
137 | echo $x | |
138 | cp -p "$WXROOT/$x" "wxPythonSrc-$VERSION/$x" | |
139 | fi | |
140 | done | |
141 | ||
142 | touch .last_copy | |
143 | fi | |
144 | ||
145 | ||
146 | cd wxPythonSrc-$VERSION | |
147 | WXDIR=`pwd` | |
148 | mkdir -p $WXDIR/bld | |
149 | cd $WXDIR/bld | |
150 | ||
151 | #---------------------------------------------------------------------- | |
152 | ||
153 | ||
154 | # Configure wxWidgets | |
155 | if [ -z "$skipconfig" ]; then | |
156 | ../configure \ | |
157 | --prefix=$PREFIX \ | |
158 | --with-mac \ | |
159 | --disable-monolithic \ | |
160 | --with-opengl \ | |
161 | --enable-geometry \ | |
162 | --enable-optimise \ | |
163 | --enable-sound \ | |
164 | --enable-display \ | |
165 | --enable-precomp=no \ | |
166 | \ | |
167 | --with-libjpeg=builtin \ | |
168 | --with-libpng=builtin \ | |
169 | --with-libtiff=builtin \ | |
170 | --with-zlib=builtin \ | |
171 | \ | |
172 | --enable-debug_flag | |
173 | ||
174 | fi | |
175 | ||
176 | # Build wxWidgets and wxPython | |
177 | if [ -z "$skipbuild" ]; then | |
178 | ||
179 | # Make wxWidgets and some contribs | |
180 | make | |
181 | make -C contrib/src/gizmos | |
182 | make -C contrib/src/ogl CXXFLAGS="-DwxUSE_DEPRECATED=0" | |
183 | make -C contrib/src/stc | |
184 | make -C contrib/src/xrc | |
185 | ||
186 | if [ ! -e $WXDIR/include/wx/gizmos ]; then | |
187 | # Make some links so the wxPython build can find all the headers it needs | |
188 | pushd $WXDIR/include/wx | |
189 | ln -s ../../contrib/include/wx/* . | |
190 | popd | |
191 | fi | |
192 | ||
193 | # Build wxPython | |
194 | cd $WXDIR/wxPython | |
195 | $PYTHON setup.py \ | |
196 | NO_SCRIPTS=1 \ | |
197 | WX_CONFIG="$WXDIR/bld/wx-config --prefix=$WXDIR --exec-prefix=$WXDIR/bld" \ | |
198 | build | |
199 | ||
200 | ||
201 | # Build wxrc (XRC resource tool) | |
202 | cd $WXDIR/bld/contrib/utils/wxrc | |
203 | make | |
204 | strip wxrc | |
205 | ||
206 | fi | |
207 | ||
208 | #---------------------------------------------------------------------- | |
209 | ||
210 | if [ -z "$skipinstall" ]; then | |
211 | # Install wxWidgets | |
212 | cd $WXDIR/bld | |
213 | make prefix=$INSTALLROOT$PREFIX install | |
214 | make -C contrib/src/gizmos prefix=$INSTALLROOT$PREFIX install | |
215 | make -C contrib/src/ogl CXXFLAGS="-DwxUSE_DEPRECATED=0" prefix=$INSTALLROOT/$PREFIX install | |
216 | make -C contrib/src/stc prefix=$INSTALLROOT$PREFIX install | |
217 | make -C contrib/src/xrc prefix=$INSTALLROOT$PREFIX install | |
218 | ||
219 | ||
220 | # and wxPython | |
221 | cd $WXDIR/wxPython | |
222 | $PYTHON setup.py \ | |
223 | NO_SCRIPTS=1 \ | |
224 | WX_CONFIG="$INSTALLROOT/$PREFIX/bin/wx-config --prefix=$INSTALLROOT/$PREFIX" \ | |
225 | install \ | |
226 | --root=$INSTALLROOT | |
227 | ||
228 | ||
229 | # Apple's Python (on Panther) sym-links the site-packages dir to | |
230 | # /Library/Python/$PYVER so we need to move the files so they are | |
231 | # installed in the physical location, not the virtual one. | |
232 | if [ "$KIND" = "panther" ]; then | |
233 | mkdir -p $INSTALLROOT/Library/Python/$PYVER | |
234 | mv $INSTALLROOT/$SITEPACKAGES/* $INSTALLROOT/Library/Python/$PYVER | |
235 | rm -r $INSTALLROOT/System | |
236 | SITEPACKAGES=/Library/Python/$PYVER | |
237 | fi | |
238 | ||
239 | ||
240 | # install wxPython's tool scripts | |
241 | mkdir -p $INSTALLROOT$BINPREFIX | |
242 | cd $WXDIR/wxPython/scripts | |
243 | python$PYVER CreateMacScripts.py $INSTALLROOT $BINPREFIX | |
244 | ||
245 | ||
246 | # Install wxrc | |
247 | cp $WXDIR/bld/contrib/utils/wxrc/wxrc $INSTALLROOT$BINPREFIX | |
248 | ||
249 | ||
250 | # install the wxPython headers | |
251 | cd $WXDIR/wxPython | |
252 | cp -R include $INSTALLROOT$PREFIX | |
253 | mkdir -p $INSTALLROOT$PREFIX/include/wx/wxPython/i_files | |
254 | cp src/*.i $INSTALLROOT$PREFIX/include/wx/wxPython/i_files | |
255 | ||
256 | ||
257 | # Set premissions for files in $INSTALLROOT | |
258 | chown -R root:admin $INSTALLROOT | |
259 | chmod -R g+w $INSTALLROOT | |
260 | fi | |
261 | ||
262 | popd | |
263 | ||
264 | #---------------------------------------------------------------------- | |
265 | ||
266 | # Make the Installer packages and disk image | |
267 | if [ -z "$skipdmg" ]; then | |
268 | ||
269 | # Remove the .pyc/.pyo files they just take up space and can be recreated | |
270 | # during the install. | |
271 | $PYTHON $PROGDIR/../zappycfiles.py $INSTALLROOT | |
272 | ||
273 | ||
274 | # Make the welcome message | |
275 | case $KIND in | |
276 | panther) W_MSG="the Panther (OS X 10.3.x) version of" ;; | |
277 | jaguar) W_MSG="the Jaguar (OS X 10.2.x) version of" ;; | |
278 | esac | |
279 | cat > $RESOURCEDIR/Welcome.txt <<EOF | |
280 | Welcome! | |
281 | ||
282 | This program will install wxPython $VERSION for $W_MSG MacPython-OSX $PYVER. | |
283 | ||
284 | You must install onto your current boot disk, even though the installer does not enforce this, otherwise things will not work. | |
285 | ||
286 | Build date: `date` | |
287 | EOF | |
288 | ||
289 | # make the preflight script | |
290 | cat > $RESOURCEDIR/preflight <<EOF | |
291 | #!/bin/sh | |
292 | # Cleanup any old install of the wxPython package | |
293 | rm -rf \$2$SITEPACKAGES/wxPython | |
294 | rm -rf \$2$SITEPACKAGES/wx | |
295 | exit 0 | |
296 | EOF | |
297 | chmod +x $RESOURCEDIR/preflight | |
298 | ||
299 | # make the postflight script | |
300 | cat > $RESOURCEDIR/postflight <<EOF | |
301 | #!/bin/sh -e | |
302 | # Compile the .py files in the wxPython pacakge | |
303 | $PYTHON \$2$PYLIB/compileall.py \$2$SITEPACKAGES/wxPython | |
304 | $PYTHON \$2$PYLIB/compileall.py \$2$SITEPACKAGES/wx | |
305 | $PYTHON -O \$2$PYLIB/compileall.py \$2$SITEPACKAGES/wxPython | |
306 | $PYTHON -O \$2$PYLIB/compileall.py \$2$SITEPACKAGES/wx | |
307 | ||
308 | ||
309 | # and all of the wxPython pacakge should be group writable | |
310 | chgrp -R admin \$2$SITEPACKAGES/wxPython | |
311 | chmod -R g+w \$2$SITEPACKAGES/wxPython | |
312 | chgrp -R admin \$2$SITEPACKAGES/wx | |
313 | chmod -R g+w \$2$SITEPACKAGES/wx | |
314 | ||
315 | exit 0 | |
316 | EOF | |
317 | chmod +x $RESOURCEDIR/postflight | |
318 | ||
319 | ||
320 | ||
321 | # Build the main Installer Package... | |
322 | rm -rf wxPythonOSX-$KIND.pkg | |
323 | python $PROGDIR/../buildpkg.py \ | |
324 | --Title=wxPythonOSX-$KIND \ | |
325 | --Version=$VERSION \ | |
326 | --Description="wxPython $VERSION for $W_MSG MacPython-OSX $PYVER" \ | |
327 | --NeedsAuthorization="YES" \ | |
328 | --Relocatable="NO" \ | |
329 | --InstallOnly="YES" \ | |
330 | $INSTALLROOT \ | |
331 | $RESOURCEDIR | |
332 | ||
333 | mv wxPythonOSX-$KIND.pkg $DMGDIR/root | |
334 | ||
335 | ||
336 | ||
337 | # Make a README.txt to go on the disk image | |
338 | cat > "$DMGDIR/root/README 1st.txt" <<EOF | |
339 | Welcome to wxPython! | |
340 | ||
341 | On this disk image you will find the installer for wxPython $VERSION for $W_MSG MacPython-OSX $PYVER. MacPython-OSX is not included. | |
342 | ||
343 | wxPython-$KIND.pkg The installer package. It contains the wxPython | |
344 | extension modules, wxMac dynamic libraries and | |
345 | headers, and some scripts for the command-line | |
346 | tools. | |
347 | ||
348 | Everything else here is optional and you can drag them out of the disk | |
349 | image and drop them whereever you want. You do need to install the above | |
350 | package before you can use any of the items below. | |
351 | ||
352 | ||
353 | Apps/wxPython Demo An application bundle version of the demo. | |
354 | (This has it's own copy of the sources within | |
355 | the bundle.) | |
356 | ||
357 | Apps/XRCed An application for editing wxPython resource | |
358 | files (XRC files.) | |
359 | ||
360 | Apps/PyCrust An application that provides an interactive | |
361 | Python shell and also namespace inspectors. | |
362 | ||
363 | ||
364 | ||
365 | Docs/wxDocs A folder containing the wxWidgets documentation | |
366 | bundled in .zip files, and a small wxPython | |
367 | application that can be used to view the docs. | |
368 | Just run viewer.pyw. | |
369 | ||
370 | Docs/licence License files. | |
371 | ||
372 | Docs/other A few readmes, change log, etc. The full | |
373 | documentation is downloadable separately. | |
374 | ||
375 | ||
376 | Samples/samples Several small sample applications that | |
377 | demonstrate how to use wxPython. | |
378 | ||
379 | Samples/demo A copy of the wxPython demo source code, | |
380 | just open the folder and run demo.pyw. | |
381 | ||
382 | Happy Hacking! | |
383 | EOF | |
384 | ||
385 | # PyAlaMode An extension of PyCrust that includes source | |
386 | # file editing capabilities. | |
387 | ||
388 | ||
389 | # wxDocs | |
390 | pushd $DMGDIR/root/Docs | |
391 | tar xzvf $TARBALLDIR/wxPythonDocs-$VERSION.tar.gz | |
392 | mv wxPython-$VERSION/docs wxDocs | |
393 | rm -r wxPython-$VERSION | |
394 | mv wxDocs/viewdocs.py wxDocs/viewdocs.pyw | |
395 | ||
396 | # license files, docs, etc. | |
397 | cp -pR $SRCROOT/wxPython/licence . | |
398 | cp -pR $SRCROOT/wxPython/docs . | |
399 | rm -rf docs/bin | |
400 | rm -rf docs/xml-raw | |
401 | mv docs other | |
402 | popd | |
403 | ||
404 | # Copy the demo and samples to the disk image from the tarball | |
405 | pushd $DMGDIR/root/Samples | |
406 | tar xzvf $TARBALLDIR/wxPythonDemo-$VERSION.tar.gz | |
407 | mv wxPython-$VERSION/* . | |
408 | rm -rf wxPython-$VERSION | |
409 | rm demo/b demo/.setup.sh | |
410 | mv demo/demo.py demo/demo.pyw | |
411 | popd | |
412 | ||
413 | ||
414 | # Make an app bundle to launch PyCrust | |
415 | $PYTHONW $PROGDIR/../buildapp.py \ | |
416 | --builddir=$DMGDIR/root/Apps \ | |
417 | --name=PyCrust \ | |
418 | --mainprogram=$INSTALLROOT$BINPREFIX/pycrust.py \ | |
419 | --iconfile=$PROGDIR/PieShell.icns \ | |
420 | build | |
421 | ||
422 | # # and PyAlaMode | |
423 | # $PYTHONW $PROGDIR/../buildapp.py \ | |
424 | # --builddir=$DMGDIR/root \ | |
425 | # --name=PyAlaMode \ | |
426 | # --mainprogram=$INSTALLROOT$BINPREFIX/pyalamode.py \ | |
427 | # --iconfile=$PROGDIR/PieShell.icns \ | |
428 | # build | |
429 | ||
430 | # Make an app to launch XRCed | |
431 | $PYTHONW $PROGDIR/../buildapp.py \ | |
432 | --builddir=$DMGDIR/root/Apps \ | |
433 | --name=XRCed \ | |
434 | --mainprogram=$INSTALLROOT$BINPREFIX/xrced.py \ | |
435 | --iconfile=$PROGDIR/XRCed.icns \ | |
436 | build | |
437 | ||
438 | # Make an app bundle to run the demo | |
439 | $PYTHONW $PROGDIR/../buildapp.py \ | |
440 | --builddir=$DMGDIR/root/Apps \ | |
441 | --name="wxPython Demo" \ | |
442 | --mainprogram=$DMGDIR/root/Samples/demo/demo.pyw \ | |
443 | --iconfile=$PROGDIR/RunDemo.icns \ | |
444 | build | |
445 | cp -pR $DMGDIR/root/Samples/demo/* "$DMGDIR/root/Apps/wxPython Demo.app/Contents/Resources" | |
446 | ||
447 | ||
448 | # and then finally make a disk image containing the packages and etc. | |
449 | $PROGDIR/../makedmg $DMGDIR/root $DMGDIR wxPythonOSX-$VERSION-$KIND-Py$PYVER | |
450 | ||
451 | echo Moving $DMGDIR/wxPythonOSX-$VERSION-$KIND-Py$PYVER.dmg to $DESTDIR | |
452 | mv $DMGDIR/wxPythonOSX-$VERSION-$KIND-Py$PYVER.dmg $DESTDIR | |
453 | fi | |
454 | ||
455 | ||
456 | # Cleanup build/install dirs | |
457 | if [ -z "$skipclean" ]; then | |
458 | echo "Cleaning up..." | |
459 | rm -rf $TMPDIR | |
460 | else | |
461 | echo "Cleanup is disabled. You should remove $TMPDIR when finished" | |
462 | fi | |
463 |