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