1 """
2 Constants for generating the layout.
3 """
4
5 __author__ = "Steve Dower <steve.dower@python.org>"
6 __version__ = "3.8"
7
8 import os
9 import struct
10 import sys
11
12
13 def _unpack_hexversion():
14 try:
15 hexversion = int(os.getenv("PYTHON_HEXVERSION"), 16)
16 except (TypeError, ValueError):
17 hexversion = sys.hexversion
18 return struct.pack(">i", hexversion)
19
20
21 def _get_suffix(field4):
22 name = {0xA0: "a", 0xB0: "b", 0xC0: "rc"}.get(field4 & 0xF0, "")
23 if name:
24 serial = field4 & 0x0F
25 return f"{name}{serial}"
26 return ""
27
28
29 VER_MAJOR, VER_MINOR, VER_MICRO, VER_FIELD4 = _unpack_hexversion()
30 VER_SUFFIX = _get_suffix(VER_FIELD4)
31 VER_FIELD3 = VER_MICRO << 8 | VER_FIELD4
32 VER_DOT = "{}.{}".format(VER_MAJOR, VER_MINOR)
33
34 PYTHON_DLL_NAME = "python{}{}.dll".format(VER_MAJOR, VER_MINOR)
35 PYTHON_STABLE_DLL_NAME = "python{}.dll".format(VER_MAJOR)
36 PYTHON_ZIP_NAME = "python{}{}.zip".format(VER_MAJOR, VER_MINOR)
37 PYTHON_PTH_NAME = "python{}{}._pth".format(VER_MAJOR, VER_MINOR)
38
39 PYTHON_CHM_NAME = "python{}{}{}{}.chm".format(
40 VER_MAJOR, VER_MINOR, VER_MICRO, VER_SUFFIX
41 )