1999-08-02 17:19:17 -03:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
"""%(program)s - script to create the latex source distribution
|
|
|
|
|
|
|
|
usage:
|
|
|
|
%(program)s [-t|--tools] release [tag]
|
|
|
|
|
|
|
|
with -t|--tools: doesn't include the documents, only the framework
|
|
|
|
|
|
|
|
without [tag]: generate from the current version that's checked in
|
|
|
|
(*NOT* what's in the current directory!)
|
|
|
|
|
|
|
|
with [tag]: generate from the named tag
|
|
|
|
"""
|
|
|
|
#* should be modified to get the Python version number automatically
|
|
|
|
# from the Makefile or someplace.
|
|
|
|
|
|
|
|
import getopt
|
|
|
|
import glob
|
|
|
|
import os
|
2000-10-10 16:35:40 -03:00
|
|
|
import re
|
1999-08-02 17:19:17 -03:00
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
import tempfile
|
|
|
|
|
2003-09-27 19:07:05 -03:00
|
|
|
try:
|
|
|
|
__file__
|
|
|
|
except NameError:
|
|
|
|
__file__ = sys.argv[0]
|
|
|
|
|
|
|
|
tools = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
Doc = os.path.dirname(tools)
|
|
|
|
patchlevel_tex = os.path.join(Doc, "commontex", "patchlevel.tex")
|
1999-08-02 17:19:17 -03:00
|
|
|
|
|
|
|
quiet = 0
|
2003-10-03 12:21:38 -03:00
|
|
|
rx = re.compile(r":ext:(?:[a-zA-Z0-9]+@)?cvs\.([a-zA-Z0-9]+).sourceforge.net:"
|
2000-10-10 16:35:40 -03:00
|
|
|
r"/cvsroot/\1")
|
1999-08-02 17:19:17 -03:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
global quiet
|
2003-10-03 12:21:38 -03:00
|
|
|
anonymous = False
|
1999-08-02 17:19:17 -03:00
|
|
|
try:
|
2003-10-03 12:21:38 -03:00
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "Aabgtzq",
|
1999-08-02 17:19:17 -03:00
|
|
|
["all", "bzip2", "gzip", "tools", "zip",
|
2003-10-03 12:21:38 -03:00
|
|
|
"quiet", "anonymous"])
|
1999-08-02 17:19:17 -03:00
|
|
|
except getopt.error, e:
|
|
|
|
usage(warning=str(e))
|
|
|
|
sys.exit(2)
|
|
|
|
if len(args) not in (1, 2):
|
|
|
|
usage(warning="wrong number of parameters")
|
|
|
|
sys.exit(2)
|
|
|
|
tools = 0
|
|
|
|
formats = {}
|
|
|
|
for opt, arg in opts:
|
|
|
|
if opt in ("-t", "--tools"):
|
|
|
|
tools = 1
|
|
|
|
elif opt in ("-q", "--quiet"):
|
|
|
|
quiet = quiet + 1
|
|
|
|
elif opt in ("-b", "--bzip2"):
|
|
|
|
formats["bzip2"] = 1
|
|
|
|
elif opt in ("-g", "--gzip"):
|
|
|
|
formats["gzip"] = 1
|
|
|
|
elif opt in ("-z", "--zip"):
|
|
|
|
formats["zip"] = 1
|
|
|
|
elif opt in ("-a", "--all"):
|
|
|
|
formats["bzip2"] = 1
|
|
|
|
formats["gzip"] = 1
|
|
|
|
formats["zip"] = 1
|
2003-10-03 12:21:38 -03:00
|
|
|
elif opt in ("-A", "--anonymous"):
|
|
|
|
anonymous = True
|
1999-08-02 17:19:17 -03:00
|
|
|
if formats:
|
|
|
|
# make order human-predictable
|
2001-01-22 17:34:20 -04:00
|
|
|
formats = formats.keys()
|
1999-08-02 17:19:17 -03:00
|
|
|
formats.sort()
|
|
|
|
else:
|
|
|
|
formats = ["gzip"]
|
|
|
|
release = args[0]
|
2006-01-02 03:22:12 -04:00
|
|
|
svntag = None
|
1999-08-02 17:19:17 -03:00
|
|
|
if len(args) > 1:
|
2006-01-02 03:22:12 -04:00
|
|
|
svntag = args[1]
|
1999-08-02 17:19:17 -03:00
|
|
|
tempdir = tempfile.mktemp()
|
|
|
|
os.mkdir(tempdir)
|
2002-08-09 17:20:50 -03:00
|
|
|
pkgdir = os.path.join(tempdir, "Python-Docs-" + release)
|
2000-10-10 16:35:40 -03:00
|
|
|
pwd = os.getcwd()
|
|
|
|
mydir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
2002-08-09 17:20:50 -03:00
|
|
|
os.chdir(tempdir)
|
2000-10-10 16:35:40 -03:00
|
|
|
if not quiet:
|
2006-01-02 03:22:12 -04:00
|
|
|
print "--- current directory is:", tempdir
|
|
|
|
if not svntag:
|
|
|
|
svntag = "trunk"
|
|
|
|
svnbase = "http://svn.python.org/projects/python"
|
|
|
|
run("svn export %s/%s/Doc Python-Docs-%s"
|
|
|
|
% (svnbase, svntag, release))
|
2003-09-27 19:07:05 -03:00
|
|
|
|
|
|
|
# Copy in the version informtation, if we're not just going to
|
|
|
|
# rip it back out:
|
|
|
|
if not tools:
|
|
|
|
if not os.path.exists(patchlevel_tex):
|
|
|
|
run(os.path.join(here, "getversioninfo"))
|
|
|
|
dest = os.path.join("Python-Docs-" + release, "commontex",
|
|
|
|
"patchlevel.tex")
|
|
|
|
shutil.copyfile(patchlevel_tex, dest)
|
|
|
|
|
|
|
|
# Copy in the license file:
|
2001-01-22 17:34:20 -04:00
|
|
|
LICENSE = os.path.normpath(
|
|
|
|
os.path.join(mydir, os.pardir, os.pardir, "LICENSE"))
|
2002-08-09 17:20:50 -03:00
|
|
|
shutil.copyfile(LICENSE, "LICENSE")
|
1999-08-02 17:19:17 -03:00
|
|
|
if tools:
|
2000-10-10 16:35:40 -03:00
|
|
|
archive = "doctools-" + release
|
1999-08-02 17:19:17 -03:00
|
|
|
# we don't want the actual documents in this case:
|
2000-10-10 16:35:40 -03:00
|
|
|
for d in ("api", "dist", "doc", "ext", "inst",
|
2003-09-27 19:07:05 -03:00
|
|
|
"lib", "mac", "ref", "tut", "commontex"):
|
2002-08-09 17:20:50 -03:00
|
|
|
shutil.rmtree(os.path.join(pkgdir, d))
|
1999-08-02 17:19:17 -03:00
|
|
|
else:
|
|
|
|
archive = "latex-" + release
|
|
|
|
|
|
|
|
# XXX should also remove the .cvsignore files at this point
|
|
|
|
|
|
|
|
os.chdir(tempdir)
|
2000-10-10 16:35:40 -03:00
|
|
|
archive = os.path.join(pwd, archive)
|
1999-08-02 17:19:17 -03:00
|
|
|
for format in formats:
|
|
|
|
if format == "bzip2":
|
2002-08-09 17:20:50 -03:00
|
|
|
run("tar cf - Python-Docs-%s | bzip2 -9 >%s.tar.bz2"
|
1999-08-02 17:19:17 -03:00
|
|
|
% (release, archive))
|
|
|
|
elif format == "gzip":
|
2002-08-09 17:20:50 -03:00
|
|
|
run("tar cf - Python-Docs-%s | gzip -9 >%s.tgz"
|
1999-08-02 17:19:17 -03:00
|
|
|
% (release, archive))
|
|
|
|
elif format == "zip":
|
2000-04-03 01:19:14 -03:00
|
|
|
if os.path.exists(archive + ".zip"):
|
|
|
|
os.unlink(archive + ".zip")
|
2002-08-09 17:20:50 -03:00
|
|
|
run("zip -q -r9 %s.zip Python-Docs-%s"
|
1999-08-02 17:19:17 -03:00
|
|
|
% (archive, release))
|
|
|
|
|
|
|
|
# clean up the work area:
|
2000-10-10 16:35:40 -03:00
|
|
|
os.chdir(pwd)
|
1999-08-02 17:19:17 -03:00
|
|
|
shutil.rmtree(tempdir)
|
|
|
|
|
|
|
|
|
|
|
|
def run(cmd):
|
|
|
|
if quiet < 2:
|
|
|
|
print "+++", cmd
|
|
|
|
if quiet:
|
2000-10-10 16:35:40 -03:00
|
|
|
cmd = "%s >/dev/null" % cmd
|
1999-08-02 17:19:17 -03:00
|
|
|
rc = os.system(cmd)
|
|
|
|
if rc:
|
|
|
|
sys.exit(rc)
|
|
|
|
|
|
|
|
|
|
|
|
def usage(warning=None):
|
|
|
|
stdout = sys.stdout
|
|
|
|
sys.stdout = sys.stderr
|
|
|
|
program = os.path.basename(sys.argv[0])
|
|
|
|
try:
|
|
|
|
if warning:
|
|
|
|
print "%s: %s\n" % (program, warning)
|
|
|
|
print __doc__ % {"program": program}
|
|
|
|
finally:
|
|
|
|
sys.stdout = stdout
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|