From f9fddfd29ac11b7224569ec3da6871bb529c76ab Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Wed, 7 Apr 2021 17:11:55 +0100 Subject: [PATCH] Squash of bpo-42504 fixes, backported to 3.7 [5291639e611dc3f55a34666036f2c3424648ba50] bpo-42504: fix for MACOSX_DEPLOYMENT_TARGET=11 (GH-23556) macOS releases numbering has changed as of macOS 11 Big Sur. Previously, major releases were of the form 10.x, 10.x+1, 10.x+2, etc; as of Big Sur, they are now x, x+1, etc, so, for example, 10.15, 10.15.1, ..., 10.15.7, 11, 11.0.1, 11.1, ..., 12, 12.1, etc. Allow Python to build with single-digit deployment target values. Patch provided by FX Coudert. Co-authored-by: FX Coudert Co-authored-by: Mitchell Hentges (backported to 3.7) [49926cf2bcc8b44d9b8f148d81979ada191dd9d5] bpo-42504: Ensure that get_config_var('MACOSX_DEPLOYMENT_TARGET') is a string (GH-24341) Co-authored-by: Ronald Oussoren --- Lib/distutils/tests/test_build_ext.py | 6 +++++- Lib/sysconfig.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py index d0428599a4..fbcd614079 100644 --- a/Lib/distutils/tests/test_build_ext.py +++ b/Lib/distutils/tests/test_build_ext.py @@ -475,7 +475,11 @@ class BuildExtTestCase(TempdirManager, target = '%02d%01d0' % target else: # for 10.10 and beyond -> "10nn00" - target = '%02d%02d00' % target + if len(target) >= 2: + target = '%02d%02d00' % target + else: + # 11 and later can have no minor version (11 instead of 11.0) + target = '%02d0000' % target deptarget_ext = Extension( 'deptarget', [deptarget_c], diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py index d15cec8dbf..7f50f93493 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -18,6 +18,11 @@ __all__ = [ 'parse_config_h', ] +# Keys for get_config_var() that are never converted to Python integers. +_ALWAYS_STR = { + 'MACOSX_DEPLOYMENT_TARGET', +} + _INSTALL_SCHEMES = { 'posix_prefix': { 'stdlib': '{installed_base}/lib/python{py_version_short}', @@ -242,6 +247,9 @@ def _parse_makefile(filename, vars=None): notdone[n] = v else: try: + if n in _ALWAYS_STR: + raise ValueError + v = int(v) except ValueError: # insert literal `$' @@ -300,6 +308,8 @@ def _parse_makefile(filename, vars=None): notdone[name] = value else: try: + if name in _ALWAYS_STR: + raise ValueError value = int(value) except ValueError: done[name] = value.strip() @@ -460,6 +470,8 @@ def parse_config_h(fp, vars=None): if m: n, v = m.group(1, 2) try: + if n in _ALWAYS_STR: + raise ValueError v = int(v) except ValueError: pass -- 2.21.1 (Apple Git-122.3)