Mercurial > cpython-lru_cache-weakref
annotate Mac/scripts/buildappbundle.py @ 27998:e27f58a50737 legacy-trunk
SF bug #690377: Dud footnote reference in distutils docs
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 21 Feb 2003 02:47:09 +0000 |
| parents | 3c64ef87d5f8 |
| children |
| rev | line source |
|---|---|
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
1 #! /usr/bin/env python |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
2 |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
3 # XXX This will be replaced by a main program in Mac/Lib/bundlebuilder.py, |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
4 # but for now this is kept so Jack won't need to change his scripts... |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
5 |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
6 |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
7 """\ |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
8 buildappbundle creates an application bundle |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
9 Usage: |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
10 buildappbundle [options] executable |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
11 Options: |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
12 --output o Output file; default executable with .app appended, short -o |
|
26343
3c64ef87d5f8
make the --link option match the original: just symlink the executable
Just van Rossum <just@letterror.com>
parents:
26341
diff
changeset
|
13 --link Symlink the executable instead of copying it, short -l |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
14 --plist file Plist file (default: generate one), short -p |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
15 --nib file Main nib file or lproj folder for Cocoa program, short -n |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
16 --resource r Extra resource file to be copied to Resources, short -r |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
17 --creator c 4-char creator code (default: '????'), short -c |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
18 --verbose increase verbosity level (default: quiet), short -v |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
19 --help This message, short -? or -h |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
20 """ |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
21 |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
22 |
|
26086
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
23 import sys |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
24 import os |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
25 import getopt |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
26 from bundlebuilder import AppBuilder |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
27 from plistlib import Plist |
|
26086
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
28 |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
29 |
|
26086
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
30 def usage(): |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
31 print __doc__ |
|
26086
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
32 sys.exit(1) |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
33 |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
34 |
|
26086
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
35 def main(): |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
36 output = None |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
37 symlink = 0 |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
38 creator = "????" |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
39 plist = None |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
40 nib = None |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
41 resources = [] |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
42 verbosity = 0 |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
43 SHORTOPTS = "o:ln:r:p:c:v?h" |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
44 LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help", |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
45 "verbose") |
|
26086
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
46 try: |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
47 options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
48 except getopt.error: |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
49 usage() |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
50 if len(args) != 1: |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
51 usage() |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
52 executable = args[0] |
|
26086
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
53 for opt, arg in options: |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
54 if opt in ('-o', '--output'): |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
55 output = arg |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
56 elif opt in ('-l', '--link'): |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
57 symlink = 1 |
|
26086
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
58 elif opt in ('-n', '--nib'): |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
59 nib = arg |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
60 elif opt in ('-r', '--resource'): |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
61 resources.append(arg) |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
62 elif opt in ('-c', '--creator'): |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
63 creator = arg |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
64 elif opt in ('-p', '--plist'): |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
65 plist = arg |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
66 elif opt in ('-v', '--verbose'): |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
67 verbosity += 1 |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
68 elif opt in ('-?', '-h', '--help'): |
|
26086
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
69 usage() |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
70 if output is not None: |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
71 builddir, bundlename = os.path.split(output) |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
72 else: |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
73 builddir = os.curdir |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
74 bundlename = None # will be derived from executable |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
75 if plist is not None: |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
76 plist = Plist.fromFile(plist) |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
77 |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
78 builder = AppBuilder(name=bundlename, executable=executable, |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
79 builddir=builddir, creator=creator, plist=plist, resources=resources, |
|
26343
3c64ef87d5f8
make the --link option match the original: just symlink the executable
Just van Rossum <just@letterror.com>
parents:
26341
diff
changeset
|
80 symlink_exec=symlink, verbosity=verbosity) |
|
26341
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
81 |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
82 if nib is not None: |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
83 resources.append(nib) |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
84 nibname, ext = os.path.splitext(os.path.basename(nib)) |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
85 if ext == '.lproj': |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
86 # Special case: if the main nib is a .lproj we assum a directory |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
87 # and use the first nib from there. XXX Look: an arbitrary pick ;-) |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
88 files = os.listdir(nib) |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
89 for f in files: |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
90 if f[-4:] == '.nib': |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
91 nibname = os.path.split(f)[1][:-4] |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
92 break |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
93 else: |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
94 nibname = "" |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
95 if nibname: |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
96 builder.plist.NSMainNibFile = nibname |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
97 if not hasattr(builder.plist, "NSPrincipalClass"): |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
98 builder.plist.NSPrincipalClass = "NSApplication" |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
99 builder.setup() |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
100 builder.build() |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
101 |
|
561185d13d5c
Replaced the bundle building code with calls to the new bundlebuilder
Just van Rossum <just@letterror.com>
parents:
26234
diff
changeset
|
102 |
|
26086
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
103 if __name__ == '__main__': |
|
34e70b89bbb7
Script to create .app bundles. Largely untested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
104 main() |
