]>
Commit | Line | Data |
---|---|---|
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 " 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 | ||
43 | if [ $# -lt 1 ]; then | |
44 | usage | |
45 | exit 1 | |
46 | fi | |
47 | ||
48 | KIND=$1 | |
49 | case $KIND in | |
50 | panther) PYTHON=/usr/bin/python ;; | |
51 | jaguar) PYTHON=/usr/local/bin/python ;; | |
52 | *) usage; exit 1 ;; | |
53 | esac | |
54 | PYTHONW=${PYTHON}w | |
55 | shift | |
56 | ||
57 | skiptar=no | |
58 | skipconfig=no | |
59 | skipbuild=no | |
60 | skipinstall=no | |
61 | skipdmg=no | |
62 | skipclean=no | |
63 | inplace=no | |
64 | ||
65 | for 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 | |
79 | done | |
80 | ||
81 | ||
82 | VERSION=`$PYTHON -c "import setup;print setup.VERSION"` | |
83 | PYVER=`$PYTHON -c "import sys; print sys.version[:3]"` | |
84 | PYPREFIX=`$PYTHON -c "import sys; print sys.exec_prefix"` | |
85 | PYLIB=$PYPREFIX/lib/python$PYVER | |
86 | SITEPACKAGES=$PYLIB/site-packages | |
87 | SHORTVER=`echo $VERSION | cut -c 1,2,3` | |
88 | ||
89 | # TODO: enable selecting unicode or ansi builds, then set this accordingly... | |
90 | CHARTYPE=ansi | |
91 | ||
92 | ||
93 | ||
94 | if [ -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 | |
99 | fi | |
100 | TARBALL=$TARBALLDIR/wxPython-src-$VERSION.tar.gz | |
101 | ||
102 | if [ ! -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 "-------------------------------------------------------" | |
108 | fi | |
109 | ||
110 | if [ ! -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 "-------------------------------------------------------" | |
116 | fi | |
117 | ||
118 | ||
119 | ||
120 | ||
121 | PREFIX=/usr/local/lib/wxPython-$VERSION | |
122 | BINPREFIX=/usr/local/bin | |
123 | ||
124 | WXROOT=`dirname $PWD` | |
125 | PROGDIR="`dirname \"$0\"`" | |
126 | TMPDIR=$PWD/_build_dmg | |
127 | ||
128 | BUILDROOT=$TMPDIR/build | |
129 | INSTALLROOT=$TMPDIR/install | |
130 | INSTALLDEVEL=$TMPDIR/install-devel | |
131 | DMGDIR=$TMPDIR/dmg | |
132 | RESOURCEDIR=$PROGDIR/resources | |
133 | DESTDIR=$PWD/dist | |
134 | SRCROOT=$BUILDROOT/wxPython-src-$VERSION | |
135 | ||
136 | ||
137 | #---------------------------------------------------------------------- | |
138 | # Setup builddirs | |
139 | ||
140 | mkdir -p $BUILDROOT | |
141 | mkdir -p $INSTALLROOT | |
142 | #mkdir -p $INSTALLDEVEL | |
143 | rm -rf $DMGDIR | |
144 | mkdir -p $DMGDIR/root/Apps | |
145 | mkdir -p $DMGDIR/root/Docs | |
146 | mkdir -p $DMGDIR/root/Samples | |
147 | ||
148 | ||
149 | pushd $BUILDROOT | |
150 | ||
151 | ||
152 | #---------------------------------------------------------------------- | |
153 | # Unpack the tarball | |
154 | ||
155 | if [ $skiptar != yes ]; then | |
156 | echo Unarchiving tarball... | |
157 | tar xzf $TARBALL | |
158 | fi | |
159 | ||
160 | if [ $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 | |
167 | else | |
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 | |
173 | fi | |
174 | ||
175 | echo "Using source tree: $WXDIR" | |
176 | echo "Using build dir: $WXBLD" | |
177 | ||
178 | #---------------------------------------------------------------------- | |
179 | ||
180 | ||
181 | # Configure wxWidgets | |
182 | if [ $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 | ||
200 | fi | |
201 | ||
202 | # Build wxWidgets and wxPython | |
203 | if [ $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 | |
224 | fi | |
225 | ||
226 | #---------------------------------------------------------------------- | |
227 | ||
228 | if [ $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 | |
278 | fi | |
279 | ||
280 | PKGDIR=`cat $INSTALLROOT/Library/Python/$PYVER/wx.pth` | |
281 | ||
282 | popd | |
283 | ||
284 | #---------------------------------------------------------------------- | |
285 | ||
286 | # Make the Installer packages and disk image | |
287 | if [ $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 | |
300 | Welcome! | |
301 | ||
302 | This program will install wxPython $VERSION for $W_MSG MacPython-OSX $PYVER. | |
303 | ||
304 | You must install onto your current boot disk, even though the installer does not enforce this, otherwise things will not work. | |
305 | ||
306 | Build date: `date` | |
307 | EOF | |
308 | ||
309 | # make the preflight script | |
310 | cat > $RESOURCEDIR/preflight <<EOF | |
311 | #!/bin/sh | |
312 | # Cleanup any old install of the wxPython package | |
313 | rm -rf \$2$SITEPACKAGES/wxPython | |
314 | rm -rf \$2$SITEPACKAGES/wx | |
315 | rm -rf \$2$SITEPACKAGES/$PKGDIR | |
316 | exit 0 | |
317 | EOF | |
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 | |
329 | chgrp -R admin \$2$SITEPACKAGES/$PKGDIR | |
330 | chmod -R g+w \$2$SITEPACKAGES/$PKGDIR | |
331 | ||
332 | exit 0 | |
333 | EOF | |
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 | |
356 | Welcome to wxPython! | |
357 | ||
358 | On 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 | ||
365 | Everything else here is optional and you can drag them out of the disk | |
366 | image and drop them wherever you want. You do need to install the above | |
367 | package 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 | ||
396 | Happy Hacking! | |
397 | EOF | |
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 | ||
407 | The wxPython-docs tarball was not found when building this disk image! | |
408 | ||
409 | EOF | |
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 | ||
428 | The wxDocsViewer application needs to be copied to your Desktop (or | |
429 | someplace else you have write access to) before you can run it, so it | |
430 | can cache some indexes within its bundle. | |
431 | ||
432 | EOF | |
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 | ||
449 | The wxPython-demo tarball was not found when building this disk image! | |
450 | ||
451 | EOF | |
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 | |
507 | fi | |
508 | ||
509 | ||
510 | # Cleanup build/install dirs | |
511 | if [ $skipclean != yes ]; then | |
512 | echo "Cleaning up..." | |
513 | rm -rf $TMPDIR | |
514 | else | |
515 | echo "Cleanup is disabled. You should remove $TMPDIR when finished" | |
516 | fi | |
517 |