]> granicus.if.org Git - python/commitdiff
Load the version information from ../Include/patchlevel.h, so there are
authorFred Drake <fdrake@acm.org>
Sat, 27 Sep 2003 22:07:05 +0000 (22:07 +0000)
committerFred Drake <fdrake@acm.org>
Sat, 27 Sep 2003 22:07:05 +0000 (22:07 +0000)
fewer changes to make to version numbers after a release.

Doc/Makefile
Doc/Makefile.deps
Doc/commontex/.cvsignore [new file with mode: 0644]
Doc/commontex/boilerplate.tex
Doc/tools/getversioninfo [new file with mode: 0755]
Doc/tools/mksourcepkg

index a6df02ffdf8b9a80ea9564700f5706853e6cd6c8..5c0dc92ea2aa0edde9ebb0ecbaa9433e8a4b0f84 100644 (file)
@@ -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)
index b7724da539948f596e37159345100916930e4342..147b1107c15d96819f3a750235729a8e4a42f6db 100644 (file)
@@ -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 (file)
index 0000000..fe65a25
--- /dev/null
@@ -0,0 +1 @@
+patchlevel.tex
index 434feaa07bf5d8d4c60abef71bfa774a524d0c86..cab70c09668fcecba8ada1828aa7a7ab98ed343f 100644 (file)
@@ -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 (executable)
index 0000000..9eb08d1
--- /dev/null
@@ -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
index e5e6e651e8965a3fb6cd2cfa94412c6a614feabd..9dbb8dc720c03bd0e06753c267c34fce680a97a1 100755 (executable)
@@ -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