mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-42504: Ensure that get_config_var('MACOSX_DEPLOYMENT_TARGET') is a string (GH-24341) (GH-24410)
* bpo-42504: Ensure that get_config_var('MACOSX_DEPLOYMENT_TARGET') is a string
(cherry picked from commit 49926cf2bc
)
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
This commit is contained in:
parent
3c8d693443
commit
d6675fee1a
6 changed files with 21 additions and 6 deletions
|
@ -54,8 +54,8 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0):
|
||||||
global _cfg_target, _cfg_target_split
|
global _cfg_target, _cfg_target_split
|
||||||
if _cfg_target is None:
|
if _cfg_target is None:
|
||||||
from distutils import sysconfig
|
from distutils import sysconfig
|
||||||
_cfg_target = str(sysconfig.get_config_var(
|
_cfg_target = sysconfig.get_config_var(
|
||||||
'MACOSX_DEPLOYMENT_TARGET') or '')
|
'MACOSX_DEPLOYMENT_TARGET') or ''
|
||||||
if _cfg_target:
|
if _cfg_target:
|
||||||
_cfg_target_split = [int(x) for x in _cfg_target.split('.')]
|
_cfg_target_split = [int(x) for x in _cfg_target.split('.')]
|
||||||
if _cfg_target:
|
if _cfg_target:
|
||||||
|
|
|
@ -455,7 +455,7 @@ class BuildExtTestCase(TempdirManager,
|
||||||
deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
|
deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
|
||||||
if deptarget:
|
if deptarget:
|
||||||
# increment the minor version number (i.e. 10.6 -> 10.7)
|
# increment the minor version number (i.e. 10.6 -> 10.7)
|
||||||
deptarget = [int(x) for x in str(deptarget).split('.')]
|
deptarget = [int(x) for x in deptarget.split('.')]
|
||||||
deptarget[-1] += 1
|
deptarget[-1] += 1
|
||||||
deptarget = '.'.join(str(i) for i in deptarget)
|
deptarget = '.'.join(str(i) for i in deptarget)
|
||||||
self._try_compile_deployment_target('<', deptarget)
|
self._try_compile_deployment_target('<', deptarget)
|
||||||
|
@ -488,7 +488,7 @@ class BuildExtTestCase(TempdirManager,
|
||||||
|
|
||||||
# get the deployment target that the interpreter was built with
|
# get the deployment target that the interpreter was built with
|
||||||
target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
|
target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
|
||||||
target = tuple(map(int, str(target).split('.')[0:2]))
|
target = tuple(map(int, target.split('.')[0:2]))
|
||||||
# format the target value as defined in the Apple
|
# format the target value as defined in the Apple
|
||||||
# Availability Macros. We can't use the macro names since
|
# Availability Macros. We can't use the macro names since
|
||||||
# at least one value we test with will not exist yet.
|
# at least one value we test with will not exist yet.
|
||||||
|
|
|
@ -18,6 +18,11 @@ __all__ = [
|
||||||
'parse_config_h',
|
'parse_config_h',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Keys for get_config_var() that are never converted to Python integers.
|
||||||
|
_ALWAYS_STR = {
|
||||||
|
'MACOSX_DEPLOYMENT_TARGET',
|
||||||
|
}
|
||||||
|
|
||||||
_INSTALL_SCHEMES = {
|
_INSTALL_SCHEMES = {
|
||||||
'posix_prefix': {
|
'posix_prefix': {
|
||||||
'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}',
|
'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}',
|
||||||
|
@ -240,6 +245,9 @@ def _parse_makefile(filename, vars=None):
|
||||||
notdone[n] = v
|
notdone[n] = v
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
if n in _ALWAYS_STR:
|
||||||
|
raise ValueError
|
||||||
|
|
||||||
v = int(v)
|
v = int(v)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# insert literal `$'
|
# insert literal `$'
|
||||||
|
@ -298,6 +306,8 @@ def _parse_makefile(filename, vars=None):
|
||||||
notdone[name] = value
|
notdone[name] = value
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
if name in _ALWAYS_STR:
|
||||||
|
raise ValueError
|
||||||
value = int(value)
|
value = int(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
done[name] = value.strip()
|
done[name] = value.strip()
|
||||||
|
@ -459,6 +469,8 @@ def parse_config_h(fp, vars=None):
|
||||||
if m:
|
if m:
|
||||||
n, v = m.group(1, 2)
|
n, v = m.group(1, 2)
|
||||||
try:
|
try:
|
||||||
|
if n in _ALWAYS_STR:
|
||||||
|
raise ValueError
|
||||||
v = int(v)
|
v = int(v)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1045,7 +1045,7 @@ class PosixTester(unittest.TestCase):
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
import sysconfig
|
import sysconfig
|
||||||
dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.0'
|
dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.0'
|
||||||
if tuple(int(n) for n in str(dt).split('.')[0:2]) < (10, 6):
|
if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6):
|
||||||
raise unittest.SkipTest("getgroups(2) is broken prior to 10.6")
|
raise unittest.SkipTest("getgroups(2) is broken prior to 10.6")
|
||||||
|
|
||||||
# 'id -G' and 'os.getgroups()' should return the same
|
# 'id -G' and 'os.getgroups()' should return the same
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Ensure that the value of
|
||||||
|
sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') is always a string,
|
||||||
|
even in when the value is parsable as an integer.
|
2
setup.py
2
setup.py
|
@ -1013,7 +1013,7 @@ class PyBuildExt(build_ext):
|
||||||
os_release = int(os.uname()[2].split('.')[0])
|
os_release = int(os.uname()[2].split('.')[0])
|
||||||
dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
|
dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
|
||||||
if (dep_target and
|
if (dep_target and
|
||||||
(tuple(int(n) for n in str(dep_target).split('.')[0:2])
|
(tuple(int(n) for n in dep_target.split('.')[0:2])
|
||||||
< (10, 5) ) ):
|
< (10, 5) ) ):
|
||||||
os_release = 8
|
os_release = 8
|
||||||
if os_release < 9:
|
if os_release < 9:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue