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