4 """%(program)s - script to create the latex source distribution
7 %(program)s [-t|--tools] release [tag]
9 with -t|--tools: doesn't include the documents, only the framework
11 without [tag]: generate from the current version that's checked in
12 (*NOT* what's in the current directory!)
14 with [tag]: generate from the named tag
16 #* should be modified to get the Python version number automatically
17 # from the Makefile or someplace.
31 rx
= re
.compile(r
":ext:(?:[a-zA-Z0-9]+)@cvs\.([a-zA-Z0-9]+).sourceforge.net:"
38 opts
, args
= getopt
.getopt(sys
.argv
[1:], "abgtzq",
39 ["all", "bzip2", "gzip", "tools", "zip",
41 except getopt
.error
, e
:
44 if len(args
) not in (1, 2):
45 usage(warning
="wrong number of parameters")
50 if opt
in ("-t", "--tools"):
52 elif opt
in ("-q", "--quiet"):
54 elif opt
in ("-b", "--bzip2"):
56 elif opt
in ("-g", "--gzip"):
58 elif opt
in ("-z", "--zip"):
60 elif opt
in ("-a", "--all"):
65 # make order human-predictable
66 formats
= formats
.keys()
74 tempdir
= tempfile
.mktemp()
76 pkgdir
= os
.path
.join(tempdir
, "Python-" + release
)
79 mydir
= os
.path
.abspath(os
.path
.dirname(sys
.argv
[0]))
80 info
= cvsinfo
.RepositoryInfo(mydir
)
81 cvsroot
= info
.get_cvsroot()
84 # If this is an authenticated SourceForge repository, convert to
85 # anonymous usage for the export/checkout, since that avoids the
88 cvsroot
= ":pserver:anonymous@cvs.%s.sourceforge.net:/cvsroot/%s" \
90 # For some reason, SourceForge/CVS doesn't seem to care that we
91 # might not have done a "cvs login" to the anonymous server.
92 # That avoids a lot of painful gunk here.
95 print "--- current directory is:", pkgdir
97 run("cvs -d%s export -r %s -d Doc python/dist/src/Doc"
100 run("cvs -Q -d%s checkout -d Doc python/dist/src/Doc" % cvsroot
)
101 # remove CVS directories
102 for p
in ('*/CVS', '*/*/CVS', '*/*/*/CVS'):
103 map(shutil
.rmtree
, glob
.glob(p
))
104 for f
in ('.cvsignore', '*/.cvsignore'):
105 map(os
.unlink
, glob
.glob(f
))
106 LICENSE
= os
.path
.normpath(
107 os
.path
.join(mydir
, os
.pardir
, os
.pardir
, "LICENSE"))
108 shutil
.copyfile(LICENSE
, "Doc/LICENSE")
110 archive
= "doctools-" + release
111 # we don't want the actual documents in this case:
112 for d
in ("api", "dist", "doc", "ext", "inst",
113 "lib", "mac", "ref", "tut"):
114 shutil
.rmtree(os
.path
.join(os
.path
.join(pkgdir
, "Doc"), d
))
116 archive
= "latex-" + release
118 # XXX should also remove the .cvsignore files at this point
121 archive
= os
.path
.join(pwd
, archive
)
122 for format
in formats
:
123 if format
== "bzip2":
124 run("tar cf - Python-%s | bzip2 -9 >%s.tar.bz2"
125 % (release
, archive
))
126 elif format
== "gzip":
127 run("tar cf - Python-%s | gzip -9 >%s.tgz"
128 % (release
, archive
))
129 elif format
== "zip":
130 if os
.path
.exists(archive
+ ".zip"):
131 os
.unlink(archive
+ ".zip")
132 run("zip -q -r9 %s.zip Python-%s"
133 % (archive
, release
))
135 # clean up the work area:
137 shutil
.rmtree(tempdir
)
144 cmd
= "%s >/dev/null" % cmd
150 def usage(warning
=None):
152 sys
.stdout
= sys
.stderr
153 program
= os
.path
.basename(sys
.argv
[0])
156 print "%s: %s\n" % (program
, warning
)
157 print __doc__
% {"program": program
}
162 if __name__
== "__main__":