blob: edcbe36ae083babfaa24b5febcf7a9b398e40446 [file] [log] [blame]
Tim Petersc78462f2002-10-11 18:25:52 +00001# An absurd workaround for the lack of arithmetic in MS's resource compiler.
2# After building Python, run this, then paste the output into the appropriate
3# part of PC\python_nt.rc.
4# Example output:
5#
6# * For 2.3a0,
7# * PY_MICRO_VERSION = 0
8# * PY_RELEASE_LEVEL = 'alpha' = 0xA
9# * PY_RELEASE_SERIAL = 1
10# *
11# * and 0*1000 + 10*10 + 1 = 101.
12# */
13# #define FIELD3 101
14
15import sys
16
17major, minor, micro, level, serial = sys.version_info
18levelnum = {'alpha': 0xA,
19 'beta': 0xB,
20 'candidate': 0xC,
21 'final': 0xF,
22 }[level]
23string = sys.version.split()[0] # like '2.3a0'
24
Collin Wintere7bf59f2007-08-30 18:39:28 +000025print(" * For %s," % string)
26print(" * PY_MICRO_VERSION = %d" % micro)
27print(" * PY_RELEASE_LEVEL = %r = %s" % (level, hex(levelnum)))
28print(" * PY_RELEASE_SERIAL = %d" % serial)
29print(" *")
Tim Petersc78462f2002-10-11 18:25:52 +000030
31field3 = micro * 1000 + levelnum * 10 + serial
32
Collin Wintere7bf59f2007-08-30 18:39:28 +000033print(" * and %d*1000 + %d*10 + %d = %d" % (micro, levelnum, serial, field3))
34print(" */")
35print("#define FIELD3", field3)