]> git.saurik.com Git - wxWidgets.git/blob - wxPython/distrib/mac/wxPythonOSX/build
added wxDebugReport
[wxWidgets.git] / wxPython / distrib / mac / wxPythonOSX / build
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 if [ "$UID" != "0" ]; then
14 echo "-------------------------------------------------------"
15 echo " WARNING: will be unable to change ownership of files"
16 echo " unless this script is run as root or via sudo"
17 echo "-------------------------------------------------------"
18 fi
19
20 #----------------------------------------------------------------------
21 # Check Parameters
22
23 function usage {
24 echo ""
25 echo "Usage: $0 [panther|jaguar] [command flags...]"
26 echo ""
27 echo " panther Build for Apple's python in /usr/bin, such as on Panther"
28 echo " jaguar Build for a python in /usr/local/bin, such as on Jaguar"
29 echo ""
30 echo "optional command flags:"
31 echo " skiptar Don't unpack the tarball"
32 echo " inplace Don't use the tarball, build from the CVS tree instead"
33 echo " (The Docs and Demo tarballs are still required for a full build.)"
34 echo " unicode Make a unicode build"
35 echo " skipconfig Don't run configure"
36 echo " skipbuild Don't build wxWidgets or wxPython"
37 echo " skipinstall Don't do the installation step"
38 echo " skipdmg Don't make the package or diskimage"
39 echo " skipclean Don't do the cleanup at the end"
40 echo ""
41 }
42
43
44 if [ $# -lt 1 ]; then
45 usage
46 exit 1
47 fi
48
49 KIND=$1
50 case $KIND in
51 panther) PYTHON=/usr/bin/python ;;
52 jaguar) PYTHON=/usr/local/bin/python ;;
53 *) usage; exit 1 ;;
54 esac
55 PYTHONW=${PYTHON}w
56 shift
57
58 skiptar=no
59 skipconfig=no
60 skipbuild=no
61 skipinstall=no
62 skipdmg=no
63 skipclean=no
64 inplace=no
65 unicode=no
66
67 for flag in $*; do
68 case ${flag} in
69 skiptar) skiptar=yes ;;
70 skipconfig) skipconfig=yes; skiptar=yes ;;
71 skipbuild) skipbuild=yes; skipconfig=yes; skiptar=yes ;;
72 skipinstall) skipinstall=yes ;;
73 skipdmg) skipdmg=yes ;;
74 skipclean) skipclean=yes ;;
75 inplace) inplace=yes; skiptar=yes ;;
76 unicode) unicode=yes ;;
77
78 *) echo "Unknown flag \"${flag}\""
79 usage
80 exit 1
81 esac
82 done
83
84
85 VERSION=`$PYTHON -c "import setup;print setup.VERSION"`
86 PYVER=`$PYTHON -c "import sys; print sys.version[:3]"`
87 PYPREFIX=`$PYTHON -c "import sys; print sys.exec_prefix"`
88 PYLIB=$PYPREFIX/lib/python$PYVER
89 SITEPACKAGES=$PYLIB/site-packages
90 SHORTVER=`echo $VERSION | cut -c 1,2,3`
91
92 if [ $unicode == yes ]; then
93 CHARTYPE=unicode
94 UNICODEOPT=--enable-unicode
95 PYUNICODEOPT=1
96 else
97 CHARTYPE=ansi
98 UNICODEOPT=--disable-unicode
99 PYUNICODEOPT=0
100 fi
101
102 #if [ "$HOSTNAME" = "bigmac.alldunn.com" ]; then
103 # MAKEJOBS="--jobs=2"
104 #fi
105
106
107 if [ -z "$TARBALLDIR" ]; then
108 # this is a spot on my fileserver where the tarballs go, adjust
109 # as needed for where you put the wxPython tarball, or set
110 # TARBALLDIR before invoking this script...
111 TARBALLDIR=/stuff/Development/wxPython/dist/$VERSION
112 fi
113 TARBALL=$TARBALLDIR/wxPython-src-$VERSION.tar.gz
114
115 if [ ! -e $TARBALLDIR/wxPython-demo-$VERSION.tar.gz ]; then
116 echo "-------------------------------------------------------"
117 echo " WARNING: Demo tarball not found, will skip building "
118 echo " the Demo app bundle and etc."
119 echo " $TARBALLDIR/wxPython-demo-$VERSION.tar.gz"
120 echo "-------------------------------------------------------"
121 fi
122
123 if [ ! -e $TARBALLDIR/wxPython-docs-$VERSION.tar.gz ]; then
124 echo "-------------------------------------------------------"
125 echo " WARNING: Docs tarball not found, will skip building "
126 echo " the the wxDocsViewer app bundle and etc."
127 echo " $TARBALLDIR/wxPython-docs-$VERSION.tar.gz"
128 echo "-------------------------------------------------------"
129 fi
130
131
132
133
134 PREFIX=/usr/local/lib/wxPython-$CHARTYPE-$VERSION
135 BINPREFIX=/usr/local/bin
136
137 WXROOT=`dirname $PWD`
138 PROGDIR="`dirname \"$0\"`"
139 TMPDIR=$PWD/_build_dmg
140
141 BUILDROOT=$TMPDIR/build
142
143 INSTALLROOT=$TMPDIR/install-root
144 INSTALLAPPS=$TMPDIR/install-apps
145
146 DMGDIR=$TMPDIR/dmg
147 DMGROOT=$DMGDIR/root
148 DMGAPPS=$DMGDIR/apps
149
150 RESOURCEDIR=$PROGDIR/resources
151 DESTDIR=$PWD/dist
152 SRCROOT=$BUILDROOT/wxPython-src-$VERSION
153
154
155 #----------------------------------------------------------------------
156 # Setup builddirs
157
158 mkdir -p $BUILDROOT
159 mkdir -p $INSTALLROOT
160 mkdir -p $INSTALLAPPS
161
162 rm -rf $DMGDIR
163 mkdir -p $DMGROOT
164 mkdir -p $DMGAPPS/Docs
165 mkdir -p $DMGAPPS/Samples
166
167
168 pushd $BUILDROOT
169
170
171 #----------------------------------------------------------------------
172 # Unpack the tarball
173
174 if [ $skiptar != yes ]; then
175 echo Unarchiving tarball...
176 tar xzf $TARBALL
177 fi
178
179 if [ $inplace = no ]; then
180 # make a build dir and cd to it.
181 cd wxPython-src-$VERSION
182 WXDIR=`pwd`
183 mkdir -p $WXDIR/bld
184 cd $WXDIR/bld
185 WXBLD=$WXDIR/bld
186 else
187
188 # If building "inplace" then our build dir will be off of the
189 # WXROOT like normal, adjust the variables to find things that
190 # way.
191 WXBLD=$WXROOT/build-$CHARTYPE
192 mkdir -p $WXBLD
193 cd $WXBLD
194 WXDIR=..
195 SRCROOT=$WXROOT
196 fi
197
198 echo "Using wx root dir: $WXROOT"
199 echo "Using build dir: $WXBLD"
200 echo "Using source tree: $WXDIR"
201
202 #----------------------------------------------------------------------
203
204 if [ $KIND = panther ]; then
205 OTHER_CFG_OPTS=--enable-mediactrl
206 fi
207
208 # Configure wxWidgets
209 if [ $skipconfig != yes ]; then
210 $WXDIR/configure \
211 --prefix=$PREFIX \
212 --with-mac \
213 --enable-monolithic \
214 --with-opengl \
215 --enable-sound \
216 --enable-display \
217 --enable-geometry \
218 --enable-debug_flag \
219 --enable-precomp=no \
220 --enable-optimise \
221 $UNICODEOPT $OTHER_CFG_OPTS
222
223 fi
224
225 # Build wxWidgets and wxPython
226 if [ $skipbuild != yes ]; then
227
228 # Make wxWidgets and some contribs
229
230 # For some reason Rez and DeRez have started locking up if run via
231 # an ssh terminal. Figure out why, but in the meantime...
232 if [ "$CHARTYPE" = "ansi" ]; then
233 echo cp /projects/wx2.5/bld/lib/libwx_macd-2.5.?.r* lib
234 cp /projects/wx2.5/bld/lib/libwx_macd-2.5.?.r* lib
235 else
236 echo cp /projects/wx2.5/bld-unicode/lib/libwx_macud-2.5.?.r* lib
237 cp /projects/wx2.5/bld-unicode/lib/libwx_macud-2.5.?.r* lib
238 fi
239 touch lib/libwx*.r*
240
241 make $MAKEJOBS
242 make $MAKEJOBS -C contrib/src/gizmos
243 make $MAKEJOBS -C contrib/src/ogl CXXFLAGS="-DwxUSE_DEPRECATED=0"
244 make $MAKEJOBS -C contrib/src/stc
245
246 # Build wxPython
247 cd $WXROOT/wxPython
248 $PYTHON setup.py \
249 UNICODE=$PYUNICODEOPT \
250 NO_SCRIPTS=1 \
251 EP_ADD_OPTS=1 \
252 WX_CONFIG="$WXBLD/wx-config --inplace" \
253 BUILD_BASE=$WXBLD/wxPython \
254 build
255 fi
256
257 #----------------------------------------------------------------------
258
259 if [ $skipinstall != yes ]; then
260 # Install wxWidgets
261 cd $WXBLD
262 make prefix=$INSTALLROOT$PREFIX install
263 make -C contrib/src/gizmos prefix=$INSTALLROOT$PREFIX install
264 make -C contrib/src/ogl CXXFLAGS="-DwxUSE_DEPRECATED=0" prefix=$INSTALLROOT/$PREFIX install
265 make -C contrib/src/stc prefix=$INSTALLROOT$PREFIX install
266
267
268 # relink wx-config with a relative link
269 cd $INSTALLROOT$PREFIX/bin
270 rm wx-config
271 ln -s ../lib/wx/config/* wx-config
272
273 # and wxPython
274 cd $WXROOT/wxPython
275 $PYTHON setup.py \
276 UNICODE=$PYUNICODEOPT \
277 NO_SCRIPTS=1 \
278 EP_ADD_OPTS=1 \
279 WX_CONFIG="$INSTALLROOT/$PREFIX/bin/wx-config --prefix=$INSTALLROOT/$PREFIX" \
280 BUILD_BASE=$WXBLD/wxPython \
281 install \
282 --root=$INSTALLROOT
283
284
285 # Apple's Python (on Panther) sym-links the site-packages dir to
286 # /Library/Python/$PYVER so we need to move the files so they are
287 # installed in the physical location, not the virtual one.
288 if [ "$KIND" = "panther" ]; then
289 if [ -e $INSTALLROOT/Library/Python/$PYVER ]; then
290 rm -r $INSTALLROOT/Library/Python/$PYVER
291 fi
292 mkdir -p $INSTALLROOT/Library/Python/$PYVER
293 mv $INSTALLROOT/$SITEPACKAGES/* $INSTALLROOT/Library/Python/$PYVER
294 rm -r $INSTALLROOT/System
295 SITEPACKAGES=/Library/Python/$PYVER
296 fi
297
298 # install wxPython's tool scripts
299 mkdir -p $INSTALLROOT$BINPREFIX
300 cd $WXROOT/wxPython/scripts
301 python$PYVER CreateMacScripts.py $INSTALLROOT $BINPREFIX
302
303
304 # Remove the .pyc/.pyo files they just take up space and can be recreated
305 # during the install.
306 pushd $WXROOT/wxPython
307 $PYTHON $PROGDIR/../zappycfiles.py $INSTALLROOT > /dev/null
308 popd
309
310 # Set premissions for files in $INSTALLROOT
311 if [ "$UID" = "0" ]; then
312 chown -R root:admin $INSTALLROOT
313 chmod -R g+w $INSTALLROOT
314 fi
315 fi
316
317 if [ "$KIND" = "panther" ]; then
318 SITEPACKAGES=/Library/Python/$PYVER
319 fi
320 PKGDIR=`cat $INSTALLROOT$SITEPACKAGES/wx.pth`
321
322 popd
323
324 #----------------------------------------------------------------------
325
326 # Make the Installer packages and disk image
327 if [ $skipdmg != yes ]; then
328
329 #-----------------------------------------------
330 # The main runtime installer package
331
332 # Make the welcome message
333 case $KIND in
334 panther) W_MSG="the Panther (OS X 10.3.x) version of" ;;
335 jaguar) W_MSG="the Jaguar (OS X 10.2.x) version of" ;;
336 esac
337
338
339 cat > $RESOURCEDIR/Welcome.txt <<EOF
340 Welcome!
341
342 This Installer package will install the wxPython $CHARTYPE runtime $VERSION for $W_MSG MacPython-OSX $PYVER. This includes:
343
344 * The wxPython packages and modules
345 * The wxWidgets shared libraries and headers
346 * Some command line tool scripts, installed to /usr/local/bin.
347
348 You must install onto your current boot disk, eventhough the installer does not enforce this, otherwise things will not work.
349
350 You can install more than one version of the wxPython runtime if you desire. The most recently installed version will be the default wxPython, but you can choose another by setting the PYTHONPATH or by using the wxversion module. See http://wiki.wxpython.org/index.cgi/MultiVersionInstalls for more details.
351
352 Build date: `date`
353 EOF
354
355 # make the preflight script
356 cat > $RESOURCEDIR/preflight <<EOF
357 #!/bin/sh
358 # Cleanup any old install of the wxPython package
359 rm -rf \$2$SITEPACKAGES/wxPython
360 rm -rf \$2$SITEPACKAGES/wx
361 rm -rf \$2$SITEPACKAGES/$PKGDIR
362 exit 0
363 EOF
364 chmod +x $RESOURCEDIR/preflight
365
366 # make the postflight script
367 cat > $RESOURCEDIR/postflight <<EOF
368 #!/bin/sh -e
369 # Compile the .py files in the wxPython pacakge
370 $PYTHON \$2$PYLIB/compileall.py \$2$SITEPACKAGES/$PKGDIR
371 $PYTHON -O \$2$PYLIB/compileall.py \$2$SITEPACKAGES/$PKGDIR
372
373 # and all of the wxPython pacakge should be group writable
374 chgrp -R admin \$2$SITEPACKAGES/$PKGDIR
375 chmod -R g+w \$2$SITEPACKAGES/$PKGDIR
376
377 exit 0
378 EOF
379 chmod +x $RESOURCEDIR/postflight
380
381
382
383 # Build the main Installer Package...
384 rm -rf wxPython${SHORTVER}-osx-$CHARTYPE-$KIND.pkg
385 python $PROGDIR/../buildpkg.py \
386 --Title=wxPython${SHORTVER}-osx-$CHARTYPE-$KIND \
387 --Version=$VERSION \
388 --Description="wxPython $CHARTYPE runtime $VERSION for $W_MSG MacPython-OSX $PYVER" \
389 --NeedsAuthorization="YES" \
390 --Relocatable="NO" \
391 --InstallOnly="YES" \
392 $INSTALLROOT \
393 $RESOURCEDIR
394
395 mv wxPython${SHORTVER}-osx-$CHARTYPE-$KIND.pkg $DMGROOT
396
397 rm $RESOURCEDIR/postflight
398 rm $RESOURCEDIR/preflight
399 rm $RESOURCEDIR/Welcome.txt
400
401
402 #-----------------------------------------------
403 # Make a README to go on the disk image
404 cat > "$DMGROOT/README 1st.txt" <<EOF
405 Welcome to wxPython!
406
407 This disk image contains the following items:
408
409 wxPython${SHORTVER}-osx-$CHARTYPE-$VERSION-$KIND
410
411 This Installer contains the wxPython runtime, compiled on a
412 $KIND OS X system, using the $CHARTYPE build of the wxWidgets
413 library. It includes the Python modules and extension
414 modules, as well as the wxWidgets libraries.
415
416 It is possible to have more than one version of the runtime
417 installed at once if you wish. The most recently installed
418 version will be the default wxPython, but you can choose
419 another by setting the PYTHONPATH or by using the wxversion
420 module. For more details see:
421 http://wiki.wxpython.org/index.cgi/MultiVersionInstalls
422
423
424 uninstall_wxPython.py
425
426 A simple tool to help you manage your installed versions of
427 wxPython. It will allow you to choose from the currently
428 installed wxPython packages and to select one for
429 uninstallation. It is a text-mode tool so you can either run
430 it from a Terminal command line, or you can open it with
431 PythonLauncher and let it create a Terminal to run it in.
432
433 NOTE: If you have versions prior to 2.5.3.1 installed, please
434 do run this uninstall tool to remove the older version.
435
436 EOF
437
438
439
440 cp $PROGDIR/../uninstall_wxPython.py $DMGROOT
441
442
443 #-----------------------------------------------
444 # Make a disk image to hold these files
445 dmgname=wxPython${SHORTVER}-osx-$CHARTYPE-$VERSION-$KIND-py$PYVER
446 $PROGDIR/../makedmg $DMGROOT $DMGDIR $dmgname
447
448 echo Moving $DMGDIR/$dmgname.dmg to $DESTDIR
449 mv $DMGDIR/$dmgname.dmg $DESTDIR
450
451
452 #---------------------------------------------------------------------------
453 # Now create app bundles for the demo, docs, and tools and make another
454 # disk image to hold it all.
455 #---------------------------------------------------------------------------
456
457 cat > "$DMGAPPS/README 1st.txt" <<EOF
458 Welcome to wxPython!
459
460 On this disk image you will find Demo, Tools, Docs, and etc. for
461 wxPython $VERSION. Everything here is optional and you can drag them
462 out of the disk image and drop them wherever you want. You will need
463 to have an installed wxPython runtime to be able to use any of them.
464
465
466 wxPython Demo An application bundle version of the demo.
467 (This has it's own copy of the demo sources
468 within the bundle.)
469
470 XRCed An application for editing wxPython resource
471 files (XRC files.)
472
473 PyCrust An application that provides an interactive
474 Python shell and also namespace inspectors.
475
476
477
478 Docs/wxDocsViewer An application that allows you to view the
479 wxWidgets documentation.
480
481 Docs/licence License files.
482
483 Docs/other A few readmes, change log, etc.
484
485
486 Samples/samples Several small sample applications that
487 demonstrate how to use wxPython.
488
489 Samples/demo A copy of the wxPython demo source code,
490 just open the folder and run demo.pyw.
491
492 Happy Hacking!
493 EOF
494
495 # PyAlaMode An extension of PyCrust that includes source
496 # file editing capabilities.
497
498
499 # wxDocs
500 if [ ! -e $TARBALLDIR/wxPython-docs-$VERSION.tar.gz ]; then
501 cat > "$DMGAPPS/Docs/Build ERROR.txt" <<EOF
502
503 The wxPython-docs tarball was not found when building this disk image!
504
505 EOF
506
507 else
508 pushd $BUILDROOT
509 tar xzvf $TARBALLDIR/wxPython-docs-$VERSION.tar.gz
510 popd
511
512 # Make an app to launch viewdocs.py
513 $PYTHONW $PROGDIR/../buildapp.py \
514 --builddir=$DMGAPPS/Docs \
515 --name=wxDocsViewer \
516 --mainprogram=$BUILDROOT/wxPython-$VERSION/docs/viewdocs.py \
517 --iconfile=$PROGDIR/Info.icns \
518 build
519
520 cp $BUILDROOT/wxPython-$VERSION/docs/*.zip $DMGAPPS/Docs/wxDocsViewer.app/Contents/Resources
521
522 cat > "$DMGAPPS/Docs/README 1st.txt" <<EOF
523
524 The wxDocsViewer application needs to be copied to your Desktop (or
525 someplace else you have write access to) before you can run it, so it
526 can cache some indexes within its bundle.
527
528 EOF
529
530 fi
531
532 # license files, docs, etc.
533 pushd $DMGAPPS/Docs
534 cp -pR $SRCROOT/wxPython/licence .
535 cp -pR $SRCROOT/wxPython/docs .
536 rm -rf docs/bin
537 rm -rf docs/xml-raw
538 mv docs other
539 popd
540
541
542 if [ ! -e $TARBALLDIR/wxPython-demo-$VERSION.tar.gz ]; then
543 cat > "$DMGAPPS/Samples/Build ERROR.txt" <<EOF
544
545 The wxPython-demo tarball was not found when building this disk image!
546
547 EOF
548 cp "$DMGAPPS/Samples/Build ERROR.txt" $DMGAPPS
549
550 else
551
552 # Copy the demo and samples to the disk image from the tarball
553 pushd $DMGAPPS/Samples
554 tar xzvf $TARBALLDIR/wxPython-demo-$VERSION.tar.gz
555 mv wxPython-$VERSION/* .
556 rm -rf wxPython-$VERSION
557 rm demo/b demo/.setup.sh
558 mv demo/demo.py demo/demo.pyw
559 popd
560
561 # Make an app bundle to run the demo
562 $PYTHONW $PROGDIR/../buildapp.py \
563 --builddir=$DMGAPPS \
564 --name="wxPython Demo" \
565 --mainprogram=$DMGAPPS/Samples/demo/demo.pyw \
566 --iconfile=$PROGDIR/RunDemo.icns \
567 build
568 cp -pR $DMGAPPS/Samples/demo/* "$DMGAPPS/wxPython Demo.app/Contents/Resources"
569 fi
570
571
572 # Make an app bundle to launch PyCrust
573 $PYTHONW $PROGDIR/../buildapp.py \
574 --builddir=$DMGAPPS \
575 --name=PyCrust \
576 --mainprogram=$INSTALLROOT$BINPREFIX/pycrust.py \
577 --iconfile=$PROGDIR/PieShell.icns \
578 build
579
580 ## TODO: PyAlaMode needs tweaked to be able to run from a bundle. It
581 ## needs to know to ignore command line parameters and etc...
582 # # and PyAlaMode
583 # $PYTHONW $PROGDIR/../buildapp.py \
584 # --builddir=$DMGAPPS \
585 # --name=PyAlaMode \
586 # --mainprogram=$INSTALLROOT$BINPREFIX/pyalamode.py \
587 # --iconfile=$PROGDIR/PieShell.icns \
588 # build
589
590 # Make an app to launch XRCed
591 $PYTHONW $PROGDIR/../buildapp.py \
592 --builddir=$DMGAPPS \
593 --name=XRCed \
594 --mainprogram=$INSTALLROOT$BINPREFIX/xrced.py \
595 --iconfile=$PROGDIR/XRCed.icns \
596 build
597
598
599
600 # and then finally make a disk image containing everything
601 dmgname=wxPython${SHORTVER}-osx-docs-demos-$VERSION-$KIND
602 $PROGDIR/../makedmg $DMGAPPS $DMGDIR $dmgname
603
604 echo Moving $DMGDIR/$dmgname.dmg to $DESTDIR
605 mv $DMGDIR/$dmgname.dmg $DESTDIR
606 fi
607
608
609 # Cleanup build/install dirs
610 if [ $skipclean != yes ]; then
611 echo "Cleaning up..."
612 rm -rf $TMPDIR
613 else
614 echo "Cleanup is disabled. You should remove $TMPDIR when finished"
615 fi
616