Mercurial > cpython-lru_cache-weakref
annotate Doc/tools/mksourcepkg @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | 1ac7e6186b6e |
| children | 510e73ae3e9e |
| rev | line source |
|---|---|
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
1 #! /usr/bin/env python |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
2 # -*- Python -*- |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
3 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
4 """%(program)s - script to create the latex source distribution |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
5 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
6 usage: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
7 %(program)s [-t|--tools] release [tag] |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
8 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
9 with -t|--tools: doesn't include the documents, only the framework |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
10 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
11 without [tag]: generate from the current version that's checked in |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
12 (*NOT* what's in the current directory!) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
13 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
14 with [tag]: generate from the named tag |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
15 """ |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
16 #* should be modified to get the Python version number automatically |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
17 # from the Makefile or someplace. |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
18 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
19 import getopt |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
20 import glob |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
21 import os |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
22 import re |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
23 import shutil |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
24 import sys |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
25 import tempfile |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
26 |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
27 import cvsinfo |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
28 |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
29 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
30 quiet = 0 |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
31 rx = re.compile(r":ext:(?:[a-zA-Z0-9]+)@cvs\.([a-zA-Z0-9]+).sourceforge.net:" |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
32 r"/cvsroot/\1") |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
33 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
34 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
35 def main(): |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
36 global quiet |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
37 try: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
38 opts, args = getopt.getopt(sys.argv[1:], "abgtzq", |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
39 ["all", "bzip2", "gzip", "tools", "zip", |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
40 "quiet"]) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
41 except getopt.error, e: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
42 usage(warning=str(e)) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
43 sys.exit(2) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
44 if len(args) not in (1, 2): |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
45 usage(warning="wrong number of parameters") |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
46 sys.exit(2) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
47 tools = 0 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
48 formats = {} |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
49 for opt, arg in opts: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
50 if opt in ("-t", "--tools"): |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
51 tools = 1 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
52 elif opt in ("-q", "--quiet"): |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
53 quiet = quiet + 1 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
54 elif opt in ("-b", "--bzip2"): |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
55 formats["bzip2"] = 1 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
56 elif opt in ("-g", "--gzip"): |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
57 formats["gzip"] = 1 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
58 elif opt in ("-z", "--zip"): |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
59 formats["zip"] = 1 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
60 elif opt in ("-a", "--all"): |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
61 formats["bzip2"] = 1 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
62 formats["gzip"] = 1 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
63 formats["zip"] = 1 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
64 if formats: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
65 # make order human-predictable |
|
16131
aa03c20e89b7
When generating the source package, copy in the LICENSE file from the main
Fred Drake <fdrake@acm.org>
parents:
15144
diff
changeset
|
66 formats = formats.keys() |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
67 formats.sort() |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
68 else: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
69 formats = ["gzip"] |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
70 release = args[0] |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
71 cvstag = None |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
72 if len(args) > 1: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
73 cvstag = args[1] |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
74 tempdir = tempfile.mktemp() |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
75 os.mkdir(tempdir) |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
76 pkgdir = os.path.join(tempdir, "Python-" + release) |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
77 os.mkdir(pkgdir) |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
78 pwd = os.getcwd() |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
79 mydir = os.path.abspath(os.path.dirname(sys.argv[0])) |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
80 info = cvsinfo.RepositoryInfo(mydir) |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
81 cvsroot = info.get_cvsroot() |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
82 m = rx.match(cvsroot) |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
83 if m: |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
84 # If this is an authenticated SourceForge repository, convert to |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
85 # anonymous usage for the export/checkout, since that avoids the |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
86 # SSH overhead. |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
87 group = m.group(1) |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
88 cvsroot = ":pserver:anonymous@cvs.%s.sourceforge.net:/cvsroot/%s" \ |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
89 % (group, group) |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
90 # For some reason, SourceForge/CVS doesn't seem to care that we |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
91 # might not have done a "cvs login" to the anonymous server. |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
92 # That avoids a lot of painful gunk here. |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
93 os.chdir(pkgdir) |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
94 if not quiet: |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
95 print "--- current directory is:", pkgdir |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
96 if cvstag: |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
97 run("cvs -d%s export -r %s -d Doc python/dist/src/Doc" |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
98 % (cvsroot, cvstag)) |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
99 else: |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
100 run("cvs -Q -d%s checkout -d Doc python/dist/src/Doc" % cvsroot) |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
101 # remove CVS directories |
|
16418
1ac7e6186b6e
Do not pass names of individual files to shutil.rmtree(); use os.unlink()
Fred Drake <fdrake@acm.org>
parents:
16131
diff
changeset
|
102 for p in ('*/CVS', '*/*/CVS', '*/*/*/CVS'): |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
103 map(shutil.rmtree, glob.glob(p)) |
|
16418
1ac7e6186b6e
Do not pass names of individual files to shutil.rmtree(); use os.unlink()
Fred Drake <fdrake@acm.org>
parents:
16131
diff
changeset
|
104 for f in ('.cvsignore', '*/.cvsignore'): |
|
1ac7e6186b6e
Do not pass names of individual files to shutil.rmtree(); use os.unlink()
Fred Drake <fdrake@acm.org>
parents:
16131
diff
changeset
|
105 map(os.unlink, glob.glob(f)) |
|
16131
aa03c20e89b7
When generating the source package, copy in the LICENSE file from the main
Fred Drake <fdrake@acm.org>
parents:
15144
diff
changeset
|
106 LICENSE = os.path.normpath( |
|
aa03c20e89b7
When generating the source package, copy in the LICENSE file from the main
Fred Drake <fdrake@acm.org>
parents:
15144
diff
changeset
|
107 os.path.join(mydir, os.pardir, os.pardir, "LICENSE")) |
|
aa03c20e89b7
When generating the source package, copy in the LICENSE file from the main
Fred Drake <fdrake@acm.org>
parents:
15144
diff
changeset
|
108 shutil.copyfile(LICENSE, "Doc/LICENSE") |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
109 if tools: |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
110 archive = "doctools-" + release |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
111 # we don't want the actual documents in this case: |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
112 for d in ("api", "dist", "doc", "ext", "inst", |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
113 "lib", "mac", "ref", "tut"): |
|
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
114 shutil.rmtree(os.path.join(os.path.join(pkgdir, "Doc"), d)) |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
115 else: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
116 archive = "latex-" + release |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
117 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
118 # XXX should also remove the .cvsignore files at this point |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
119 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
120 os.chdir(tempdir) |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
121 archive = os.path.join(pwd, archive) |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
122 for format in formats: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
123 if format == "bzip2": |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
124 run("tar cf - Python-%s | bzip2 -9 >%s.tar.bz2" |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
125 % (release, archive)) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
126 elif format == "gzip": |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
127 run("tar cf - Python-%s | gzip -9 >%s.tgz" |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
128 % (release, archive)) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
129 elif format == "zip": |
|
12215
774817285b8c
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11165
diff
changeset
|
130 if os.path.exists(archive + ".zip"): |
|
774817285b8c
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11165
diff
changeset
|
131 os.unlink(archive + ".zip") |
|
774817285b8c
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11165
diff
changeset
|
132 run("zip -q -r9 %s.zip Python-%s" |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
133 % (archive, release)) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
134 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
135 # clean up the work area: |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
136 os.chdir(pwd) |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
137 shutil.rmtree(tempdir) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
138 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
139 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
140 def run(cmd): |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
141 if quiet < 2: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
142 print "+++", cmd |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
143 if quiet: |
|
15144
6b01fc22ef6e
Substantially revise to handle the fact that Python CVS is no longer in a
Fred Drake <fdrake@acm.org>
parents:
12215
diff
changeset
|
144 cmd = "%s >/dev/null" % cmd |
|
11165
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
145 rc = os.system(cmd) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
146 if rc: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
147 sys.exit(rc) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
148 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
149 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
150 def usage(warning=None): |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
151 stdout = sys.stdout |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
152 sys.stdout = sys.stderr |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
153 program = os.path.basename(sys.argv[0]) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
154 try: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
155 if warning: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
156 print "%s: %s\n" % (program, warning) |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
157 print __doc__ % {"program": program} |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
158 finally: |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
159 sys.stdout = stdout |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
160 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
161 |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
162 if __name__ == "__main__": |
|
a4aba205038e
Re-implementation of mktarball.sh as a more portable Python script;
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
163 main() |
