Bug 820285 - Use distutils.version.StrictVersion in OSX version tests; r=gps

DONTBUILD (NPOTB)
This commit is contained in:
Jorge Luis Mendez 2012-12-12 19:56:48 -05:00
parent 162ea60ae2
commit e2ecc82c18
2 changed files with 13 additions and 16 deletions

View File

@ -58,12 +58,10 @@ class Bootstrapper(object):
elif sys.platform.startswith('darwin'):
# TODO Support Darwin platforms that aren't OS X.
major, minor, point = map(int, platform.mac_ver()[0].split('.'))
osx_version = platform.mac_ver()[0]
cls = OSXBootstrapper
args['major'] = major
args['minor'] = minor
args['point'] = point
args['version'] = osx_version
elif sys.platform.startswith('openbsd'):
cls = OpenBSDBootstrapper

View File

@ -77,13 +77,13 @@ We will install a modern version of Clang through Homebrew.
class OSXBootstrapper(BaseBootstrapper):
def __init__(self, major, minor, point):
def __init__(self, version):
BaseBootstrapper.__init__(self)
if major == 10 and minor < 6:
raise Exception('OS X 10.6 or above is required.')
self.os_version = StrictVersion(version)
self.os_version = minor
if self.os_version < StrictVersion('10.6'):
raise Exception('OS X 10.6 or above is required.')
def install_system_packages(self):
self.ensure_xcode()
@ -91,14 +91,14 @@ class OSXBootstrapper(BaseBootstrapper):
self.ensure_homebrew_packages()
def ensure_xcode(self):
if self.os_version < 7:
if self.os_version < StrictVersion('10.7'):
if not os.path.exists('/Developer/Applications/Xcode.app'):
print(XCODE_REQUIRED_LEGACY)
subprocess.check_call(['open', XCODE_LEGACY])
sys.exit(1)
elif self.os_version >= 7:
elif self.os_version >= StrictVersion('10.7'):
if not os.path.exists('/Applications/Xcode.app'):
print(XCODE_REQUIRED)
@ -113,14 +113,14 @@ class OSXBootstrapper(BaseBootstrapper):
output = self.check_output(['/usr/bin/xcrun', 'clang'],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
if 'license' in e.output:
xcodebuild = self.which('xcodebuild')
subprocess.check_call([xcodebuild, '-license'])
if 'license' in e.output:
xcodebuild = self.which('xcodebuild')
subprocess.check_call([xcodebuild, '-license'])
# Even then we're not done! We need to install the Xcode command line tools.
# As of Mountain Lion, apparently the only way to do this is to go through a
# menu dialog inside Xcode itself. We're not making this up.
if self.os_version >= 7:
if self.os_version >= StrictVersion('10.7'):
if not os.path.exists('/usr/bin/clang'):
print(XCODE_COMMAND_LINE_TOOLS_MISSING)
print(INSTALL_XCODE_COMMAND_LINE_TOOLS_STEPS)
@ -179,9 +179,8 @@ class OSXBootstrapper(BaseBootstrapper):
subprocess.check_call([brew, '-v', 'install', package])
if self.os_version < 7 and 'llvm' not in installed:
if self.os_version < StrictVersion('10.7') and 'llvm' not in installed:
print(HOMEBREW_OLD_CLANG)
subprocess.check_call([brew, '-v', 'install', 'llvm',
'--with-clang', '--all-targets'])