summaryrefslogtreecommitdiff
path: root/PC/layout/support/constants.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2019-11-20 09:30:47 -0800
committerGitHub <noreply@github.com>2019-11-20 09:30:47 -0800
commitde148f263fba75cd10d2cb010fe9c495cee4ec83 (patch)
tree7559853c00252bb9e300e6815ee3615a90e3973b /PC/layout/support/constants.py
parentabce2d9bc6b990831d303f4cf9f2de8a6712a1fc (diff)
downloadcpython-git-de148f263fba75cd10d2cb010fe9c495cee4ec83.tar.gz
bpo-33125: Add support for building and releasing Windows ARM64 packages (GH-16828)
Note that the support is not actually enabled yet, and so we won't be publishing these packages. However, for those who want to build it themselves (even by reusing the Azure Pipelines definition), it's now relatively easy to enable.
Diffstat (limited to 'PC/layout/support/constants.py')
-rw-r--r--PC/layout/support/constants.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/PC/layout/support/constants.py b/PC/layout/support/constants.py
index d76fa3bbf3..a8647631e9 100644
--- a/PC/layout/support/constants.py
+++ b/PC/layout/support/constants.py
@@ -5,15 +5,31 @@ Constants for generating the layout.
__author__ = "Steve Dower <steve.dower@python.org>"
__version__ = "3.8"
+import os
+import re
import struct
import sys
-VER_MAJOR, VER_MINOR, VER_MICRO, VER_FIELD4 = struct.pack(">i", sys.hexversion)
+
+def _unpack_hexversion():
+ try:
+ hexversion = int(os.getenv("PYTHON_HEXVERSION"), 16)
+ except (TypeError, ValueError):
+ hexversion = sys.hexversion
+ return struct.pack(">i", sys.hexversion)
+
+
+def _get_suffix(field4):
+ name = {0xA0: "a", 0xB0: "b", 0xC0: "c"}.get(field4 & 0xF0, "")
+ if name:
+ serial = field4 & 0x0F
+ return f"{name}{serial}"
+ return ""
+
+
+VER_MAJOR, VER_MINOR, VER_MICRO, VER_FIELD4 = _unpack_hexversion()
+VER_SUFFIX = _get_suffix(VER_FIELD4)
VER_FIELD3 = VER_MICRO << 8 | VER_FIELD4
-VER_NAME = {"alpha": "a", "beta": "b", "candidate": "rc"}.get(
- sys.version_info.releaselevel, ""
-)
-VER_SERIAL = sys.version_info.serial if VER_NAME else ""
VER_DOT = "{}.{}".format(VER_MAJOR, VER_MINOR)
PYTHON_DLL_NAME = "python{}{}.dll".format(VER_MAJOR, VER_MINOR)
@@ -21,8 +37,6 @@ PYTHON_STABLE_DLL_NAME = "python{}.dll".format(VER_MAJOR)
PYTHON_ZIP_NAME = "python{}{}.zip".format(VER_MAJOR, VER_MINOR)
PYTHON_PTH_NAME = "python{}{}._pth".format(VER_MAJOR, VER_MINOR)
-PYTHON_CHM_NAME = "python{}{}{}{}{}.chm".format(
- VER_MAJOR, VER_MINOR, VER_MICRO, VER_NAME, VER_SERIAL
+PYTHON_CHM_NAME = "python{}{}{}{}.chm".format(
+ VER_MAJOR, VER_MINOR, VER_MICRO, VER_SUFFIX
)
-
-IS_X64 = sys.maxsize > 2 ** 32