Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1:/tmp/cvs-serv2614/tools Modified Files: mksourcepkg Added Files: getversioninfo Log Message: Load the version information from ../Include/patchlevel.h, so there are fewer changes to make to version numbers after a release. --- NEW FILE: getversioninfo --- #! /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: mksourcepkg =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/mksourcepkg,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** mksourcepkg 9 Aug 2002 20:20:50 -0000 1.6 --- mksourcepkg 27 Sep 2003 22:07:04 -0000 1.7 *************** *** 27,30 **** --- 27,38 ---- 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 *************** *** 103,108 **** for p in ('*/CVS', '*/*/CVS', '*/*/*/CVS'): map(shutil.rmtree, glob.glob(p)) ! for f in ('.cvsignore', '*/.cvsignore'): ! map(os.unlink, glob.glob(f)) LICENSE = os.path.normpath( os.path.join(mydir, os.pardir, os.pardir, "LICENSE")) --- 111,127 ---- for p in ('*/CVS', '*/*/CVS', '*/*/*/CVS'): map(shutil.rmtree, glob.glob(p)) ! 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")) *************** *** 112,116 **** # we don't want the actual documents in this case: for d in ("api", "dist", "doc", "ext", "inst", ! "lib", "mac", "ref", "tut"): shutil.rmtree(os.path.join(pkgdir, d)) else: --- 131,135 ---- # we don't want the actual documents in this case: for d in ("api", "dist", "doc", "ext", "inst", ! "lib", "mac", "ref", "tut", "commontex"): shutil.rmtree(os.path.join(pkgdir, d)) else: