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