diff options
-rw-r--r-- | Doc/Makefile | 11 | ||||
-rw-r--r-- | Doc/Makefile.deps | 1 | ||||
-rw-r--r-- | Doc/commontex/.cvsignore | 1 | ||||
-rw-r--r-- | Doc/commontex/boilerplate.tex | 4 | ||||
-rwxr-xr-x | Doc/tools/getversioninfo | 72 | ||||
-rwxr-xr-x | Doc/tools/mksourcepkg | 25 |
6 files changed, 105 insertions, 9 deletions
diff --git a/Doc/Makefile b/Doc/Makefile index a6df02f..5c0dc92 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -64,9 +64,14 @@ PAPER=letter INFODIR= info TOOLSDIR= tools -# This is the *documentation* release, and is used to construct the file -# names of the downloadable tarballs. -RELEASE=2.4a0 +# This is the *documentation* release, and is used to construct the +# file names of the downloadable tarballs. It is initialized by the +# getversioninfo script to ensure that the right version number is +# used; the script will also write commontex/patchlevel.tex if that +# doesn't exist or needs to be changed. Documents which depend on the +# version number should use \input{patchlevel} and include +# commontex/patchlevel.tex in their dependencies. +RELEASE=$(shell $(PYTHON) tools/getversioninfo) PYTHON= python DVIPS= dvips -N0 -t $(PAPER) diff --git a/Doc/Makefile.deps b/Doc/Makefile.deps index b7724da..147b110 100644 --- a/Doc/Makefile.deps +++ b/Doc/Makefile.deps @@ -7,6 +7,7 @@ INDEXSTYLES=texinputs/python.ist COMMONTEX=commontex/copyright.tex \ commontex/license.tex \ + commontex/patchlevel.tex \ commontex/boilerplate.tex MANSTYLES= texinputs/fncychap.sty \ diff --git a/Doc/commontex/.cvsignore b/Doc/commontex/.cvsignore new file mode 100644 index 0000000..fe65a25 --- /dev/null +++ b/Doc/commontex/.cvsignore @@ -0,0 +1 @@ +patchlevel.tex diff --git a/Doc/commontex/boilerplate.tex b/Doc/commontex/boilerplate.tex index 434feaa..cab70c0 100644 --- a/Doc/commontex/boilerplate.tex +++ b/Doc/commontex/boilerplate.tex @@ -6,6 +6,4 @@ } \date{\today} % XXX update before final release! -\release{2.4} % software release, not documentation -\setreleaseinfo{a0} % empty for final release -\setshortversion{2.4} % major.minor only for software +\input{patchlevel} % include Python version information diff --git a/Doc/tools/getversioninfo b/Doc/tools/getversioninfo new file mode 100755 index 0000000..9eb08d1 --- /dev/null +++ b/Doc/tools/getversioninfo @@ -0,0 +1,72 @@ +#! /usr/bin/env python + +import os +import re +import sys + +try: + __file__ +except NameError: + __file__ = sys.argv[0] + +tools = os.path.dirname(os.path.abspath(__file__)) +Doc = os.path.dirname(tools) +src = os.path.dirname(Doc) +patchlevel_h = os.path.join(src, "Include", "patchlevel.h") + +# This won't pick out all #defines, but it will pick up the ones we +# care about. +rx = re.compile(r"\s*#define\s+([a-zA-Z][a-zA-Z_0-9]*)\s+([a-zA-Z_0-9]+)") + +d = {} +f = open(patchlevel_h) +for line in f: + m = rx.match(line) + if m is not None: + name, value = m.group(1, 2) + d[name] = value +f.close() + +release = "%s.%s" % (d["PY_MAJOR_VERSION"], d["PY_MINOR_VERSION"]) +micro = int(d["PY_MICRO_VERSION"]) +shortversion = release +if micro != 0: + release += "." + str(micro) +level = d["PY_RELEASE_LEVEL"] + +suffixes = { + "PY_RELEASE_LEVEL_ALPHA": "a", + "PY_RELEASE_LEVEL_BETA": "b", + "PY_RELEASE_LEVEL_GAMMA": "c", + } + +releaseinfo = "" +if level != "PY_RELEASE_LEVEL_FINAL": + releaseinfo = suffixes[level] + str(int(d["PY_RELEASE_SERIAL"])) + +def write_file(name, text): + """Write text to a file if the file doesn't exist or if text + differs from any existing content.""" + if os.path.exists(name): + f = open(name, "r") + s = f.read() + f.close() + if s == text: + return + f = open(name, "w") + f.write(text) + f.close() + +patchlevel_tex = os.path.join(Doc, "commontex", "patchlevel.tex") +Makefile_version = os.path.join(Doc, "Makefile.version") + +write_file(patchlevel_tex, + "%% This file is generated by ../tools/getversioninfo;\n" + "%% do not edit manually.\n" + "\n" + "\\release{%s}\n" + "\\setreleaseinfo{%s}\n" + "\\setshortversion{%s}\n" + % (release, releaseinfo, shortversion)) + +print release + releaseinfo diff --git a/Doc/tools/mksourcepkg b/Doc/tools/mksourcepkg index e5e6e65..9dbb8dc 100755 --- a/Doc/tools/mksourcepkg +++ b/Doc/tools/mksourcepkg @@ -26,6 +26,14 @@ import tempfile import cvsinfo +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") quiet = 0 rx = re.compile(r":ext:(?:[a-zA-Z0-9]+)@cvs\.([a-zA-Z0-9]+).sourceforge.net:" @@ -102,8 +110,19 @@ def main(): # remove CVS directories for p in ('*/CVS', '*/*/CVS', '*/*/*/CVS'): map(shutil.rmtree, glob.glob(p)) - for f in ('.cvsignore', '*/.cvsignore'): - map(os.unlink, glob.glob(f)) + for f in ('.cvsignore', '*/.cvsignore'): + map(os.unlink, glob.glob(f)) + + # 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: LICENSE = os.path.normpath( os.path.join(mydir, os.pardir, os.pardir, "LICENSE")) shutil.copyfile(LICENSE, "LICENSE") @@ -111,7 +130,7 @@ def main(): archive = "doctools-" + release # we don't want the actual documents in this case: for d in ("api", "dist", "doc", "ext", "inst", - "lib", "mac", "ref", "tut"): + "lib", "mac", "ref", "tut", "commontex"): shutil.rmtree(os.path.join(pkgdir, d)) else: archive = "latex-" + release |