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.
30 __file__
= sys
.argv
[0]
32 tools
= os
.path
.dirname(os
.path
.abspath(__file__
))
33 Doc
= os
.path
.dirname(tools
)
34 patchlevel_tex
= os
.path
.join(Doc
, "commontex", "patchlevel.tex")
37 rx
= re
.compile(r
":ext:(?:[a-zA-Z0-9]+@)?cvs\.([a-zA-Z0-9]+).sourceforge.net:"
45 opts
, args
= getopt
.getopt(sys
.argv
[1:], "Aabgtzq",
46 ["all", "bzip2", "gzip", "tools", "zip",
47 "quiet", "anonymous"])
48 except getopt
.error
, e
:
51 if len(args
) not in (1, 2):
52 usage(warning
="wrong number of parameters")
57 if opt
in ("-t", "--tools"):
59 elif opt
in ("-q", "--quiet"):
61 elif opt
in ("-b", "--bzip2"):
63 elif opt
in ("-g", "--gzip"):
65 elif opt
in ("-z", "--zip"):
67 elif opt
in ("-a", "--all"):
71 elif opt
in ("-A", "--anonymous"):
74 # make order human-predictable
75 formats
= formats
.keys()
83 tempdir
= tempfile
.mktemp()
85 pkgdir
= os
.path
.join(tempdir
, "Python-Docs-" + release
)
87 mydir
= os
.path
.abspath(os
.path
.dirname(sys
.argv
[0]))
90 print "--- current directory is:", tempdir
93 svnbase
= "http://svn.python.org/projects/python"
94 run("svn export %s/%s/Doc Python-Docs-%s"
95 % (svnbase
, svntag
, release
))
97 # Copy in the version informtation, if we're not just going to
100 if not os
.path
.exists(patchlevel_tex
):
101 run(os
.path
.join(here
, "getversioninfo"))
102 dest
= os
.path
.join("Python-Docs-" + release
, "commontex",
104 shutil
.copyfile(patchlevel_tex
, dest
)
106 # Copy in the license file:
107 LICENSE
= os
.path
.normpath(
108 os
.path
.join(mydir
, os
.pardir
, os
.pardir
, "LICENSE"))
109 shutil
.copyfile(LICENSE
, "LICENSE")
111 archive
= "doctools-" + release
112 # we don't want the actual documents in this case:
113 for d
in ("api", "dist", "doc", "ext", "inst",
114 "lib", "mac", "ref", "tut", "commontex"):
115 shutil
.rmtree(os
.path
.join(pkgdir
, d
))
117 archive
= "latex-" + release
119 # XXX should also remove the .cvsignore files at this point
122 archive
= os
.path
.join(pwd
, archive
)
123 for format
in formats
:
124 if format
== "bzip2":
125 run("tar cf - Python-Docs-%s | bzip2 -9 >%s.tar.bz2"
126 % (release
, archive
))
127 elif format
== "gzip":
128 run("tar cf - Python-Docs-%s | gzip -9 >%s.tgz"
129 % (release
, archive
))
130 elif format
== "zip":
131 if os
.path
.exists(archive
+ ".zip"):
132 os
.unlink(archive
+ ".zip")
133 run("zip -q -r9 %s.zip Python-Docs-%s"
134 % (archive
, release
))
136 # clean up the work area:
138 shutil
.rmtree(tempdir
)
145 cmd
= "%s >/dev/null" % cmd
151 def usage(warning
=None):
153 sys
.stdout
= sys
.stderr
154 program
= os
.path
.basename(sys
.argv
[0])
157 print "%s: %s\n" % (program
, warning
)
158 print __doc__
% {"program": program
}
163 if __name__
== "__main__":