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