summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/tools')
-rwxr-xr-xDoc/tools/getversioninfo72
-rwxr-xr-xDoc/tools/mksourcepkg25
2 files changed, 94 insertions, 3 deletions
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