2 #----------------------------------------------------------------------
3 # Build wxMac and wxPythonOSX from the tarball and then make an
4 # Installer package out of it.
8 spectemplate
=distrib
/wxPythonFull.spec.
in
10 if [ ! -d wxPython
-o ! -e ${spectemplate} ]; then
11 echo "Please run this script from the root wxPython directory."
15 if [ "$UID" != "0" ]; then
16 echo "-------------------------------------------------------"
17 echo " WARNING: I will be unable to change ownership of files"
18 echo " unless this script is run as root or via sudo"
19 echo "-------------------------------------------------------"
22 #----------------------------------------------------------------------
27 echo "Usage: $0 PYVER [command flags...]"
29 echo " PYVER Python version to use to do the build. A"
30 echo " matching python\$PYVER must be found on the PATH"
32 echo "optional command flags:"
33 echo " skiptar Don't unpack the tarball"
34 echo " inplace Don't use the tarball, build from the CVS tree instead"
35 echo " (The Docs and Demo tarballs are still required for a full build.)"
36 echo " reswig Regenerate SWIG wrappers"
37 echo " universal Generate Universal wxWidgets binary (requires Universal Python "
38 echo " to general Universal wxPython)."
39 echo " unicode Make a unicode build"
40 echo " skipconfig Don't run configure"
41 echo " skipbuild Don't build wxWidgets or wxPython"
42 echo " skipinstall Don't do the installation step"
43 echo " skipdmg Don't make the package or diskimage"
44 echo " skipclean Don't do the cleanup at the end"
50 if [ "$PYVER" != "" ] && which python
$PYVER && which pythonw
$PYVER; then
51 PYTHON
=`which python$PYVER`
52 PYTHONW
=`which pythonw$PYVER`
74 skiptar
) skiptar
=yes ;;
75 skipconfig
) skipconfig
=yes; skiptar
=yes ;;
76 skipbuild
) skipbuild
=yes; skipconfig
=yes; skiptar
=yes ;;
77 skipinstall
) skipinstall
=yes ;;
78 skipdmg
) skipdmg
=yes ;;
79 skipclean
) skipclean
=yes ;;
80 inplace
) inplace
=yes; skiptar
=yes ;;
81 unicode
) unicode
=yes ;;
85 universal
) universal
=yes ;;
86 *) echo "Unknown flag \"${flag}\""
94 OSX_VERSION
=`sw_vers -productVersion`
95 OSX_VERSION
=${OSX_VERSION:0:4}
98 10.4) TAG
=macosx10.4
;;
99 10.3) TAG
=macosx10.3
;;
100 10.2) TAG
=macosx10.2
;;
104 if [ $universal = yes ]; then
110 VERSION
=`$PYTHON -c "import setup;print setup.VERSION"`
111 SHORTVER
=`echo $VERSION | cut -c 1,2,3`
112 PYPREFIX
=`$PYTHON -c "import sys; print sys.exec_prefix"`
113 PYLIB
=$PYPREFIX/lib
/python
$PYVER
114 SITEPACKAGES
=$PYLIB/site
-packages
116 if [ $unicode == yes ]; then
118 UNICODEOPT
=--enable-unicode
122 UNICODEOPT
=--disable-unicode
126 if [ $debug == yes ]; then
127 DEBUG_FLAG
=--enable-debug
130 DEBUG_FLAG
=--enable-debug_flag
135 # Test if the python we are using is the System installed framework
136 # or one that was installed by the user. This changes where the
137 # site-packages (or its alias) is located in the installer tree.
139 if [ -e /Library
/Python
/$PYVER ] && [ `dirname $PYTHON` == "/usr/bin" ]; then
145 if [ -z "$TARBALLDIR" ]; then
146 # this is a spot on my fileserver where the tarballs go, adjust
147 # as needed for where you put the wxPython tarball, or set
148 # TARBALLDIR before invoking this script...
149 TARBALLDIR
=/stuff
/Development
/wxPython
/dist
/$VERSION
151 TARBALL
=$TARBALLDIR/wxPython
-src-$VERSION.
tar.bz2
153 if [ ! -e $TARBALLDIR/wxPython
-demo-$VERSION.
tar.bz2
]; then
154 echo "-------------------------------------------------------"
155 echo " WARNING: Demo tarball not found, will skip building "
156 echo " the Demo app bundle and etc."
157 echo " $TARBALLDIR/wxPython-demo-$VERSION.tar.bz2"
158 echo "-------------------------------------------------------"
161 if [ ! -e $TARBALLDIR/wxPython
-docs-$VERSION.
tar.bz2
]; then
162 echo "-------------------------------------------------------"
163 echo " WARNING: Docs tarball not found, will skip building "
164 echo " the the wxDocsViewer app bundle and etc."
165 echo " $TARBALLDIR/wxPython-docs-$VERSION.tar.bz2"
166 echo "-------------------------------------------------------"
172 PREFIX
=/usr
/local
/lib
/wxPython
-$CHARTYPE-$VERSION
173 BINPREFIX
=/usr
/local
/bin
175 SWIGBIN
=/opt
/swig
/bin
/swig
176 WXROOT
=`dirname $PWD`
177 PROGDIR
="`dirname \"$0\"`"
178 TMPDIR
=$PWD/_build_dmg
180 BUILDROOT
=$TMPDIR/build
182 INSTALLROOT
=$TMPDIR/install-root
183 INSTALLAPPS
=$TMPDIR/install-apps
189 RESOURCEDIR
=$PROGDIR/resources
191 SRCROOT
=$BUILDROOT/wxPython
-src-$VERSION
194 #----------------------------------------------------------------------
198 mkdir -p $INSTALLROOT
199 mkdir -p $INSTALLAPPS
203 mkdir -p $DMGAPPS/Docs
204 mkdir -p $DMGAPPS/Samples
206 if [ ! -d $DESTDIR ]; then
213 #----------------------------------------------------------------------
216 if [ $skiptar != yes ]; then
217 echo Unarchiving tarball...
221 if [ $inplace = no
]; then
222 # make a build dir and cd to it.
223 cd wxPython
-src-$VERSION
230 # If building "inplace" then our build dir will be off of the
231 # WXROOT like normal, adjust the variables to find things that
233 WXBLD
=$WXROOT/build
-$CHARTYPE
240 echo "Using wx root dir: $WXROOT"
241 echo "Using build dir: $WXBLD"
242 echo "Using source tree: $WXDIR"
244 #----------------------------------------------------------------------
246 if [ $OSX_VERSION = 10.3 -o $OSX_VERSION = 10.4 ]; then
247 OTHER_CFG_OPTS
=--enable-mediactrl
250 # Configure wxWidgets
251 if [ $skipconfig != yes -a $universal != yes ]; then
255 --enable-monolithic \
260 --enable-graphics_ctx \
262 --enable-precomp=no \
264 --disable-debugreport \
265 --disable-precompiled-headers \
266 $UNICODEOPT $OTHER_CFG_OPTS
270 # Build wxWidgets and wxPython
271 if [ $skipbuild != yes ]; then
273 # Make wxWidgets and some contribs
274 WXBLD_CONFIG
="$WXBLD/wx-config"
275 if [ $universal = yes ]; then
277 export BUILDPREFIX
=$PREFIX
278 export INSTALLDIR
=$INSTALLROOT$PREFIX
279 $WXDIR/distrib
/scripts
/mac
/macbuild wxpython universal
$CHARTYPE
282 make $MAKEJOBS -C contrib
/src
/animate
283 make $MAKEJOBS -C contrib
/src
/gizmos
284 make $MAKEJOBS -C contrib
/src
/stc
288 if [ $reswig = yes ]; then
295 UNICODE
=$PYUNICODEOPT \
298 WX_CONFIG
="$WXBLD_CONFIG --inplace" \
299 BUILD_BASE
=$WXBLD/wxPython \
305 #----------------------------------------------------------------------
307 if [ $skipinstall != yes ]; then
310 if [ $universal != yes ]; then
311 make prefix
=$INSTALLROOT$PREFIX install
312 make -C contrib
/src
/animate prefix
=$INSTALLROOT$PREFIX install
313 make -C contrib
/src
/gizmos prefix
=$INSTALLROOT$PREFIX install
314 make -C contrib
/src
/stc prefix
=$INSTALLROOT$PREFIX install
317 # relink wx-config with a relative link
318 cd $INSTALLROOT$PREFIX/bin
320 ln -s ..
/lib
/wx
/config
/* wx
-config
325 UNICODE
=$PYUNICODEOPT \
328 WX_CONFIG
="$INSTALLROOT$PREFIX/bin/wx-config --prefix=$INSTALLROOT$PREFIX" \
329 BUILD_BASE
=$WXBLD/wxPython \
334 # Apple's Python Framework (such as what comes with Panther)
335 # sym-links the site-packages dir in the framework to
336 # /Library/Python/$PYVER so we need to move the files so they are
337 # installed in the physical location, not the virtual one.
338 if [ $APPLE_PYTHON == yes ]; then
339 if [ -e $INSTALLROOT/Library
/Python
/$PYVER ]; then
340 rm -r $INSTALLROOT/Library
/Python
/$PYVER
342 mkdir -p $INSTALLROOT/Library
/Python
/$PYVER
343 mv $INSTALLROOT/$SITEPACKAGES/* $INSTALLROOT/Library
/Python
/$PYVER
344 rm -r $INSTALLROOT/System
345 SITEPACKAGES
=/Library
/Python
/$PYVER
348 # install wxPython's tool scripts
349 mkdir -p $INSTALLROOT$BINPREFIX
350 cd $WXROOT/wxPython
/scripts
351 python
$PYVER CreateMacScripts.py
$INSTALLROOT $BINPREFIX
354 # Remove the .pyc/.pyo files they just take up space and can be recreated
355 # during the install.
356 pushd $WXROOT/wxPython
357 $PYTHON $PROGDIR/..
/zappycfiles.py
$INSTALLROOT > /dev
/null
360 # Set premissions for files in $INSTALLROOT
361 if [ "$UID" = "0" ]; then
362 chown
-R root
:admin
$INSTALLROOT
363 chmod -R g
+w
$INSTALLROOT
367 if [ $APPLE_PYTHON == yes ]; then
368 SITEPACKAGES
=/Library
/Python
/$PYVER
370 PKGDIR
=`cat $INSTALLROOT$SITEPACKAGES/wx.pth`
374 #----------------------------------------------------------------------
376 # Make the Installer packages and disk image
377 if [ $skipdmg != yes ]; then
379 #-----------------------------------------------
380 # The main runtime installer package
382 # Make the welcome message
384 10.4) W_MSG
="the Tiger (OS X 10.4.x Intel) version of" ;;
385 10.3) W_MSG
="the Panther (OS X 10.3.x) version of" ;;
386 10.2) W_MSG
="the Jaguar (OS X 10.2.x) version of" ;;
389 if [ $universal == yes ]; then
390 W_MSG
="the Universal (OS X 10.4.x and above) version of"
394 cat > $RESOURCEDIR/Welcome.txt
<<EOF
397 This Installer package will install the wxPython $CHARTYPE runtime $VERSION for $W_MSG MacPython-OSX $PYVER. This includes:
399 * The wxPython packages and modules
400 * The wxWidgets shared libraries and headers
401 * Some command line tool scripts, installed to /usr/local/bin.
403 You must install onto your current boot disk, eventhough the installer does not enforce this, otherwise things will not work.
405 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.
410 # make the preflight script
411 cat > $RESOURCEDIR/preflight
<<EOF
413 # Cleanup any old install of the wxPython package
414 rm -rf \$2$SITEPACKAGES/wxPython
415 rm -rf \$2$SITEPACKAGES/wx
416 rm -rf \$2$SITEPACKAGES/$PKGDIR
419 chmod +x
$RESOURCEDIR/preflight
421 # make the postflight script
422 cat > $RESOURCEDIR/postflight
<<EOF
424 # Compile the .py files in the wxPython pacakge
425 $PYTHON \$2$PYLIB/compileall.py \$2$SITEPACKAGES/$PKGDIR
426 $PYTHON -O \$2$PYLIB/compileall.py \$2$SITEPACKAGES/$PKGDIR
428 # and all of the wxPython pacakge should be group writable
429 chgrp -R admin \$2$SITEPACKAGES/$PKGDIR
430 chmod -R g+w \$2$SITEPACKAGES/$PKGDIR
434 chmod +x
$RESOURCEDIR/postflight
438 # Build the main Installer Package...
439 PKGNAME
=wxPython
${SHORTVER}-osx-$CHARTYPE-$TAG
440 if [ $PYVER != 2.3 ]; then
441 PKGNAME
=wxPython
${SHORTVER}-osx-$CHARTYPE-$TAG-py$PYVER
444 $PYTHON $PROGDIR/..
/buildpkg.py \
447 --Description="wxPython $CHARTYPE runtime $VERSION for $W_MSG MacPython-OSX $PYVER" \
448 --NeedsAuthorization="YES" \
450 --InstallOnly="YES" \
454 mv $PKGNAME.pkg
$DMGROOT/$PKGNAME.pkg
456 rm $RESOURCEDIR/postflight
457 rm $RESOURCEDIR/preflight
458 rm $RESOURCEDIR/Welcome.txt
461 #-----------------------------------------------
462 # Make a README to go on the disk image
463 cat > "$DMGROOT/README 1st.txt" <<EOF
466 This disk image contains the following items:
468 wxPython${SHORTVER}-osx-$CHARTYPE-$VERSION-$KIND
470 This Installer contains the wxPython runtime, compiled on a
471 $KIND OS X system, using the $CHARTYPE build of the wxWidgets
472 library. It includes the Python modules and extension
473 modules, as well as the wxWidgets libraries.
475 It is possible to have more than one version of the runtime
476 installed at once if you wish. The most recently installed
477 version will be the default wxPython, but you can choose
478 another by setting the PYTHONPATH or by using the wxversion
479 module. For more details see:
480 http://wiki.wxpython.org/index.cgi/MultiVersionInstalls
483 uninstall_wxPython.py
485 A simple tool to help you manage your installed versions of
486 wxPython. It will allow you to choose from the currently
487 installed wxPython packages and to select one for
488 uninstallation. It is a text-mode tool so you can either run
489 it from a Terminal command line, or you can open it with
490 PythonLauncher and let it create a Terminal to run it in.
492 NOTE: If you have versions prior to 2.5.3.1 installed, please
493 do run this uninstall tool to remove the older version.
499 cp $PROGDIR/..
/uninstall_wxPython.py
$DMGROOT
502 #-----------------------------------------------
503 # Make a disk image to hold these files
504 dmgname
=wxPython
${SHORTVER}-osx-$CHARTYPE-$VERSION-$TAG-py$PYVER
505 $PROGDIR/..
/makedmg
$DMGROOT $DMGDIR $dmgname
507 echo Moving
$DMGDIR/$dmgname.dmg to
$DESTDIR
508 mv $DMGDIR/$dmgname.dmg
$DESTDIR/$dmgname.dmg
511 #---------------------------------------------------------------------------
512 # Now create app bundles for the demo, docs, and tools and make another
513 # disk image to hold it all.
514 #---------------------------------------------------------------------------
516 cat > "$DMGAPPS/README 1st.txt" <<EOF
519 On this disk image you will find Demo, Tools, Docs, and etc. for
520 wxPython $VERSION. Everything here is optional and you can drag them
521 out of the disk image and drop them wherever you want. You will need
522 to have an installed wxPython runtime to be able to use any of them.
525 wxPython Demo An application bundle version of the demo.
526 (This has it's own copy of the demo sources
529 XRCed An application for editing wxPython resource
532 PyCrust An application that provides an interactive
533 Python shell and also namespace inspectors.
537 Docs/wxDocsViewer An application that allows you to view the
538 wxWidgets documentation.
540 Docs/licence License files.
542 Docs/other A few readmes, change log, etc.
545 Samples/samples Several small sample applications that
546 demonstrate how to use wxPython.
548 Samples/demo A copy of the wxPython demo source code,
549 just open the folder and run demo.pyw.
554 # PyAlaMode An extension of PyCrust that includes source
555 # file editing capabilities.
559 if [ ! -e $TARBALLDIR/wxPython
-docs-$VERSION.
tar.bz2
]; then
560 cat > "$DMGAPPS/Docs/Build ERROR.txt" <<EOF
562 The wxPython-docs tarball was not found when building this disk image!
568 tar xjvf
$TARBALLDIR/wxPython
-docs-$VERSION.
tar.bz2
571 # Make an app to launch viewdocs.py
572 $PYTHONW $PROGDIR/..
/buildapp.py \
573 --builddir=$DMGAPPS/Docs \
574 --name=wxDocsViewer \
575 --mainprogram=$BUILDROOT/wxPython
-$VERSION/docs
/viewdocs.py \
576 --iconfile=$PROGDIR/Info.icns \
579 cp $BUILDROOT/wxPython
-$VERSION/docs
/*.
zip $DMGAPPS/Docs
/wxDocsViewer.app
/Contents
/Resources
581 cat > "$DMGAPPS/Docs/README 1st.txt" <<EOF
583 The wxDocsViewer application needs to be copied to your Desktop (or
584 someplace else you have write access to) before you can run it, so it
585 can cache some indexes within its bundle.
591 # license files, docs, etc.
593 cp -pR $SRCROOT/wxPython
/licence .
594 cp -pR $SRCROOT/wxPython
/docs .
601 if [ ! -e $TARBALLDIR/wxPython
-demo-$VERSION.
tar.bz2
]; then
602 cat > "$DMGAPPS/Samples/Build ERROR.txt" <<EOF
604 The wxPython-$VERSION-demo tarball was not found when building this disk image!
607 cp "$DMGAPPS/Samples/Build ERROR.txt" $DMGAPPS
611 # Copy the demo and samples to the disk image from the tarball
612 pushd $DMGAPPS/Samples
613 tar xjvf
$TARBALLDIR/wxPython
-demo-$VERSION.
tar.bz2
614 mv wxPython
-$VERSION/* .
615 rm -rf wxPython
-$VERSION
616 rm -f demo
/b demo
/.setup.sh
617 mv demo
/demo.py demo
/demo.pyw
620 # Make an app bundle to run the demo
621 $PYTHONW $PROGDIR/..
/buildapp.py \
622 --builddir=$DMGAPPS \
623 --name="wxPython Demo" \
624 --mainprogram=$DMGAPPS/Samples
/demo
/demo.pyw \
625 --iconfile=$PROGDIR/RunDemo.icns \
627 cp -pR $DMGAPPS/Samples
/demo
/* "$DMGAPPS/wxPython Demo.app/Contents/Resources"
631 # Make an app bundle to launch PyCrust
632 $PYTHONW $PROGDIR/..
/buildapp.py \
633 --builddir=$DMGAPPS \
635 --mainprogram=$INSTALLROOT$BINPREFIX/pycrust.py \
636 --iconfile=$PROGDIR/PieShell.icns \
639 ## TODO: PyAlaMode needs tweaked to be able to run from a bundle. It
640 ## needs to know to ignore command line parameters and etc...
642 # $PYTHONW $PROGDIR/../buildapp.py \
643 # --builddir=$DMGAPPS \
645 # --mainprogram=$INSTALLROOT$BINPREFIX/pyalamode.py \
646 # --iconfile=$PROGDIR/PieShell.icns \
649 # Make an app to launch XRCed
650 $PYTHONW $PROGDIR/..
/buildapp.py \
651 --builddir=$DMGAPPS \
653 --mainprogram=$INSTALLROOT$BINPREFIX/xrced.py \
654 --iconfile=$PROGDIR/XRCed.icns \
659 # and then finally make a disk image containing everything
660 dmgname
=wxPython
${SHORTVER}-osx-docs-demos-$VERSION-$TAG-py$PYVER
661 $PROGDIR/..
/makedmg
$DMGAPPS $DMGDIR $dmgname
663 echo Moving
$DMGDIR/$dmgname.dmg to
$DESTDIR
664 mv $DMGDIR/$dmgname.dmg
$DESTDIR/$dmgname.dmg
668 # Cleanup build/install dirs
669 if [ $skipclean != yes ]; then
670 echo "Cleaning up..."
673 echo "Cleanup is disabled. You should remove $TMPDIR when finished"