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.
32 __file__
= sys
.argv
[0]
34 tools
= os
.path
.dirname(os
.path
.abspath(__file__
))
35 Doc
= os
.path
.dirname(tools
)
36 patchlevel_tex
= os
.path
.join(Doc
, "commontex", "patchlevel.tex")
39 rx
= re
.compile(r
":ext:(?:[a-zA-Z0-9]+@)?cvs\.([a-zA-Z0-9]+).sourceforge.net:"
47 opts
, args
= getopt
.getopt(sys
.argv
[1:], "Aabgtzq",
48 ["all", "bzip2", "gzip", "tools", "zip",
49 "quiet", "anonymous"])
50 except getopt
.error
, e
:
53 if len(args
) not in (1, 2):
54 usage(warning
="wrong number of parameters")
59 if opt
in ("-t", "--tools"):
61 elif opt
in ("-q", "--quiet"):
63 elif opt
in ("-b", "--bzip2"):
65 elif opt
in ("-g", "--gzip"):
67 elif opt
in ("-z", "--zip"):
69 elif opt
in ("-a", "--all"):
73 elif opt
in ("-A", "--anonymous"):
76 # make order human-predictable
77 formats
= formats
.keys()
85 tempdir
= tempfile
.mktemp()
87 pkgdir
= os
.path
.join(tempdir
, "Python-Docs-" + release
)
90 mydir
= os
.path
.abspath(os
.path
.dirname(sys
.argv
[0]))
91 info
= cvsinfo
.RepositoryInfo(mydir
)
92 cvsroot
= info
.get_cvsroot()
95 # If this is an authenticated SourceForge repository, convert to
96 # anonymous usage for the export/checkout, since that avoids the
99 cvsroot
= ":pserver:anonymous@cvs.%s.sourceforge.net:/cvsroot/%s" \
101 # For some reason, SourceForge/CVS doesn't seem to care that we
102 # might not have done a "cvs login" to the anonymous server.
103 # That avoids a lot of painful gunk here.
106 print "--- current directory is:", pkgdir
108 run("cvs -d%s export -r %s -d Python-Docs-%s python/dist/src/Doc"
109 % (cvsroot
, cvstag
, release
))
111 run("cvs -Q -d%s checkout -d Python-Docs-%s python/dist/src/Doc"
112 % (cvsroot
, release
))
113 # remove CVS directories
114 for p
in ('*/CVS', '*/*/CVS', '*/*/*/CVS'):
115 map(shutil
.rmtree
, glob
.glob(p
))
116 for f
in ('.cvsignore', '*/.cvsignore'):
117 map(os
.unlink
, glob
.glob(f
))
119 # Copy in the version informtation, if we're not just going to
122 if not os
.path
.exists(patchlevel_tex
):
123 run(os
.path
.join(here
, "getversioninfo"))
124 dest
= os
.path
.join("Python-Docs-" + release
, "commontex",
126 shutil
.copyfile(patchlevel_tex
, dest
)
128 # Copy in the license file:
129 LICENSE
= os
.path
.normpath(
130 os
.path
.join(mydir
, os
.pardir
, os
.pardir
, "LICENSE"))
131 shutil
.copyfile(LICENSE
, "LICENSE")
133 archive
= "doctools-" + release
134 # we don't want the actual documents in this case:
135 for d
in ("api", "dist", "doc", "ext", "inst",
136 "lib", "mac", "ref", "tut", "commontex"):
137 shutil
.rmtree(os
.path
.join(pkgdir
, d
))
139 archive
= "latex-" + release
141 # XXX should also remove the .cvsignore files at this point
144 archive
= os
.path
.join(pwd
, archive
)
145 for format
in formats
:
146 if format
== "bzip2":
147 run("tar cf - Python-Docs-%s | bzip2 -9 >%s.tar.bz2"
148 % (release
, archive
))
149 elif format
== "gzip":
150 run("tar cf - Python-Docs-%s | gzip -9 >%s.tgz"
151 % (release
, archive
))
152 elif format
== "zip":
153 if os
.path
.exists(archive
+ ".zip"):
154 os
.unlink(archive
+ ".zip")
155 run("zip -q -r9 %s.zip Python-Docs-%s"
156 % (archive
, release
))
158 # clean up the work area:
160 shutil
.rmtree(tempdir
)
167 cmd
= "%s >/dev/null" % cmd
173 def usage(warning
=None):
175 sys
.stdout
= sys
.stderr
176 program
= os
.path
.basename(sys
.argv
[0])
179 print "%s: %s\n" % (program
, warning
)
180 print __doc__
% {"program": program
}
185 if __name__
== "__main__":