Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c8083cf

Browse files
committed
Load the version information from ../Include/patchlevel.h, so there are
fewer changes to make to version numbers after a release.
1 parent 43b5e40 commit c8083cf

6 files changed

Lines changed: 105 additions & 9 deletions

File tree

Doc/Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,14 @@ PAPER=letter
6464
INFODIR= info
6565
TOOLSDIR= tools
6666

67-
# This is the *documentation* release, and is used to construct the file
68-
# names of the downloadable tarballs.
69-
RELEASE=2.4a0
67+
# This is the *documentation* release, and is used to construct the
68+
# file names of the downloadable tarballs. It is initialized by the
69+
# getversioninfo script to ensure that the right version number is
70+
# used; the script will also write commontex/patchlevel.tex if that
71+
# doesn't exist or needs to be changed. Documents which depend on the
72+
# version number should use \input{patchlevel} and include
73+
# commontex/patchlevel.tex in their dependencies.
74+
RELEASE=$(shell $(PYTHON) tools/getversioninfo)
7075

7176
PYTHON= python
7277
DVIPS= dvips -N0 -t $(PAPER)

Doc/Makefile.deps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ INDEXSTYLES=texinputs/python.ist
77

88
COMMONTEX=commontex/copyright.tex \
99
commontex/license.tex \
10+
commontex/patchlevel.tex \
1011
commontex/boilerplate.tex
1112

1213
MANSTYLES= texinputs/fncychap.sty \

Doc/commontex/.cvsignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
patchlevel.tex

Doc/commontex/boilerplate.tex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@
66
}
77

88
\date{\today} % XXX update before final release!
9-
\release{2.4} % software release, not documentation
10-
\setreleaseinfo{a0} % empty for final release
11-
\setshortversion{2.4} % major.minor only for software
9+
\input{patchlevel} % include Python version information

Doc/tools/getversioninfo

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#! /usr/bin/env python
2+
3+
import os
4+
import re
5+
import sys
6+
7+
try:
8+
__file__
9+
except NameError:
10+
__file__ = sys.argv[0]
11+
12+
tools = os.path.dirname(os.path.abspath(__file__))
13+
Doc = os.path.dirname(tools)
14+
src = os.path.dirname(Doc)
15+
patchlevel_h = os.path.join(src, "Include", "patchlevel.h")
16+
17+
# This won't pick out all #defines, but it will pick up the ones we
18+
# care about.
19+
rx = re.compile(r"\s*#define\s+([a-zA-Z][a-zA-Z_0-9]*)\s+([a-zA-Z_0-9]+)")
20+
21+
d = {}
22+
f = open(patchlevel_h)
23+
for line in f:
24+
m = rx.match(line)
25+
if m is not None:
26+
name, value = m.group(1, 2)
27+
d[name] = value
28+
f.close()
29+
30+
release = "%s.%s" % (d["PY_MAJOR_VERSION"], d["PY_MINOR_VERSION"])
31+
micro = int(d["PY_MICRO_VERSION"])
32+
shortversion = release
33+
if micro != 0:
34+
release += "." + str(micro)
35+
level = d["PY_RELEASE_LEVEL"]
36+
37+
suffixes = {
38+
"PY_RELEASE_LEVEL_ALPHA": "a",
39+
"PY_RELEASE_LEVEL_BETA": "b",
40+
"PY_RELEASE_LEVEL_GAMMA": "c",
41+
}
42+
43+
releaseinfo = ""
44+
if level != "PY_RELEASE_LEVEL_FINAL":
45+
releaseinfo = suffixes[level] + str(int(d["PY_RELEASE_SERIAL"]))
46+
47+
def write_file(name, text):
48+
"""Write text to a file if the file doesn't exist or if text
49+
differs from any existing content."""
50+
if os.path.exists(name):
51+
f = open(name, "r")
52+
s = f.read()
53+
f.close()
54+
if s == text:
55+
return
56+
f = open(name, "w")
57+
f.write(text)
58+
f.close()
59+
60+
patchlevel_tex = os.path.join(Doc, "commontex", "patchlevel.tex")
61+
Makefile_version = os.path.join(Doc, "Makefile.version")
62+
63+
write_file(patchlevel_tex,
64+
"%% This file is generated by ../tools/getversioninfo;\n"
65+
"%% do not edit manually.\n"
66+
"\n"
67+
"\\release{%s}\n"
68+
"\\setreleaseinfo{%s}\n"
69+
"\\setshortversion{%s}\n"
70+
% (release, releaseinfo, shortversion))
71+
72+
print release + releaseinfo

Doc/tools/mksourcepkg

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ import tempfile
2626

2727
import cvsinfo
2828

29+
try:
30+
__file__
31+
except NameError:
32+
__file__ = sys.argv[0]
33+
34+
tools = os.path.dirname(os.path.abspath(__file__))
35+
Doc = os.path.dirname(tools)
36+
patchlevel_tex = os.path.join(Doc, "commontex", "patchlevel.tex")
2937

3038
quiet = 0
3139
rx = re.compile(r":ext:(?:[a-zA-Z0-9]+)@cvs\.([a-zA-Z0-9]+).sourceforge.net:"
@@ -102,16 +110,27 @@ def main():
102110
# remove CVS directories
103111
for p in ('*/CVS', '*/*/CVS', '*/*/*/CVS'):
104112
map(shutil.rmtree, glob.glob(p))
105-
for f in ('.cvsignore', '*/.cvsignore'):
106-
map(os.unlink, glob.glob(f))
113+
for f in ('.cvsignore', '*/.cvsignore'):
114+
map(os.unlink, glob.glob(f))
115+
116+
# Copy in the version informtation, if we're not just going to
117+
# rip it back out:
118+
if not tools:
119+
if not os.path.exists(patchlevel_tex):
120+
run(os.path.join(here, "getversioninfo"))
121+
dest = os.path.join("Python-Docs-" + release, "commontex",
122+
"patchlevel.tex")
123+
shutil.copyfile(patchlevel_tex, dest)
124+
125+
# Copy in the license file:
107126
LICENSE = os.path.normpath(
108127
os.path.join(mydir, os.pardir, os.pardir, "LICENSE"))
109128
shutil.copyfile(LICENSE, "LICENSE")
110129
if tools:
111130
archive = "doctools-" + release
112131
# we don't want the actual documents in this case:
113132
for d in ("api", "dist", "doc", "ext", "inst",
114-
"lib", "mac", "ref", "tut"):
133+
"lib", "mac", "ref", "tut", "commontex"):
115134
shutil.rmtree(os.path.join(pkgdir, d))
116135
else:
117136
archive = "latex-" + release

0 commit comments

Comments
 (0)