Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 04cdfa1

Browse files
committed
Issue #21811: Anticipated fixes to 3.x and 2.7 for OS X 10.10 Yosemite.
1 parent 975735f commit 04cdfa1

6 files changed

Lines changed: 40 additions & 18 deletions

File tree

Lib/_osx_support.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,16 @@ def get_platform_osx(_config_vars, osname, release, machine):
450450
# case and disallow installs.
451451
cflags = _config_vars.get(_INITPRE+'CFLAGS',
452452
_config_vars.get('CFLAGS', ''))
453-
if ((macrelease + '.') >= '10.4.' and
454-
'-arch' in cflags.strip()):
453+
if macrelease:
454+
try:
455+
macrelease = tuple(int(i) for i in macrelease.split('.')[0:2])
456+
except ValueError:
457+
macrelease = (10, 0)
458+
else:
459+
# assume no universal support
460+
macrelease = (10, 0)
461+
462+
if (macrelease >= (10, 4)) and '-arch' in cflags.strip():
455463
# The universal build will build fat binaries, but not on
456464
# systems before 10.4
457465

Lib/distutils/tests/test_build_ext.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,16 @@ def _try_compile_deployment_target(self, operator, target):
444444

445445
# get the deployment target that the interpreter was built with
446446
target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
447-
target = tuple(map(int, target.split('.')))
448-
target = '%02d%01d0' % target
447+
target = tuple(map(int, target.split('.')[0:2]))
448+
# format the target value as defined in the Apple
449+
# Availability Macros. We can't use the macro names since
450+
# at least one value we test with will not exist yet.
451+
if target[1] < 10:
452+
# for 10.1 through 10.9.x -> "10n0"
453+
target = '%02d%01d0' % target
454+
else:
455+
# for 10.10 and beyond -> "10nn00"
456+
target = '%02d%02d00' % target
449457
deptarget_ext = Extension(
450458
'deptarget',
451459
[deptarget_c],

Lib/test/test__osx_support.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ def test__save_modified_value_unchanged(self):
109109

110110
def test__supports_universal_builds(self):
111111
import platform
112-
self.assertEqual(platform.mac_ver()[0].split('.') >= ['10', '4'],
112+
mac_ver_tuple = tuple(int(i) for i in
113+
platform.mac_ver()[0].split('.')[0:2])
114+
self.assertEqual(mac_ver_tuple >= (10, 4),
113115
_osx_support._supports_universal_builds())
114116

115117
def test__find_appropriate_compiler(self):

Lib/test/test_posix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ def test_getgroups(self):
768768
if sys.platform == 'darwin':
769769
import sysconfig
770770
dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.0'
771-
if float(dt) < 10.6:
771+
if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6):
772772
raise unittest.SkipTest("getgroups(2) is broken prior to 10.6")
773773

774774
# 'id -G' and 'os.getgroups()' should return the same

Mac/BuildScript/build-installer.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,19 @@ def getFullVersion():
150150
# $MACOSX_DEPLOYMENT_TARGET -> minimum OS X level
151151
DEPTARGET = '10.3'
152152

153-
target_cc_map = {
153+
def getDeptargetTuple():
154+
return tuple([int(n) for n in DEPTARGET.split('.')[0:2]])
155+
156+
def getTargetCompilers():
157+
target_cc_map = {
154158
'10.3': ('gcc-4.0', 'g++-4.0'),
155159
'10.4': ('gcc-4.0', 'g++-4.0'),
156160
'10.5': ('gcc-4.2', 'g++-4.2'),
157161
'10.6': ('gcc-4.2', 'g++-4.2'),
158-
'10.7': ('clang', 'clang++'),
159-
'10.8': ('clang', 'clang++'),
160-
'10.9': ('clang', 'clang++'),
161-
}
162+
}
163+
return target_cc_map.get(DEPTARGET, ('clang', 'clang++') )
162164

163-
CC, CXX = target_cc_map[DEPTARGET]
165+
CC, CXX = getTargetCompilers()
164166

165167
PYTHON_3 = getVersionTuple() >= (3, 0)
166168

@@ -193,10 +195,10 @@ def getFullVersion():
193195
def library_recipes():
194196
result = []
195197

196-
LT_10_5 = bool(DEPTARGET < '10.5')
198+
LT_10_5 = bool(getDeptargetTuple() < (10, 5))
197199

198200
# Disable for now
199-
if False: # if (DEPTARGET > '10.5') and (getVersionTuple() >= (3, 5)):
201+
if False: # if (getDeptargetTuple() > (10, 5)) and (getVersionTuple() >= (3, 5)):
200202
result.extend([
201203
dict(
202204
name="Tcl 8.5.15",
@@ -304,7 +306,7 @@ def library_recipes():
304306
),
305307
])
306308

307-
if DEPTARGET < '10.5':
309+
if getDeptargetTuple() < (10, 5):
308310
result.extend([
309311
dict(
310312
name="Bzip2 1.0.6",
@@ -458,7 +460,7 @@ def pkg_recipes():
458460
)
459461
)
460462

461-
if DEPTARGET < '10.4' and not PYTHON_3:
463+
if getDeptargetTuple() < (10, 4) and not PYTHON_3:
462464
result.append(
463465
dict(
464466
name="PythonSystemFixes",
@@ -679,7 +681,7 @@ def parseOptions(args=None):
679681
SDKPATH=os.path.abspath(SDKPATH)
680682
DEPSRC=os.path.abspath(DEPSRC)
681683

682-
CC, CXX=target_cc_map[DEPTARGET]
684+
CC, CXX = getTargetCompilers()
683685

684686
print("Settings:")
685687
print(" * Source directory:", SRCDIR)

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,9 @@ def detect_modules(self):
697697
if host_platform == 'darwin':
698698
os_release = int(os.uname()[2].split('.')[0])
699699
dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
700-
if dep_target and dep_target.split('.') < ['10', '5']:
700+
if (dep_target and
701+
(tuple(int(n) for n in dep_target.split('.')[0:2])
702+
< (10, 5) ) ):
701703
os_release = 8
702704
if os_release < 9:
703705
# MacOSX 10.4 has a broken readline. Don't try to build

0 commit comments

Comments
 (0)