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