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