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