зеркало из https://github.com/mozilla/gecko-dev.git
Bug 792202 - Make mozboot work with Python 2.6.1; r=jhammel DONTBUILD
Python 2.6.1 is what ships on OS X 10.6 and we want to support mozboot there. We include 3 fixes: 1) optparse doesn't like unicode as its initial argument 2) __init__(**kwargs) doesn't like unicode keys 3) subprocess does not have check_output We took the easy solution of removing unicode_literals. This should have no significant consequences.
This commit is contained in:
Родитель
f35f4e230e
Коммит
d2ae2988b7
|
@ -10,7 +10,9 @@
|
|||
# bootstrap support. It does this through various means, including fetching
|
||||
# content from the upstream source repository.
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
# If we add unicode_literals, optparse breaks on Python 2.6.1 (which is needed
|
||||
# to support OS X 10.6).
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
|
|
@ -52,3 +52,23 @@ class BaseBootstrapper(object):
|
|||
command.extend(packages)
|
||||
|
||||
self.run_as_root(command)
|
||||
|
||||
def check_output(self, *args, **kwargs):
|
||||
"""Run subprocess.check_output even if Python doesn't provide it."""
|
||||
fn = getattr(subprocess, 'check_output', BaseBootstrapper._check_output)
|
||||
|
||||
return fn(*args, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def _check_output(*args, **kwargs):
|
||||
"""Python 2.6 compatible implementation of subprocess.check_output."""
|
||||
proc = subprocess.Popen(stdout=subprocess.PIPE, *args, **kwargs)
|
||||
output, unused_err = proc.communicate()
|
||||
retcode = proc.poll()
|
||||
if retcode:
|
||||
cmd = kwargs.get('args', args[0])
|
||||
e = subprocess.CalledProcessError(retcode, cmd)
|
||||
e.output = output
|
||||
raise e
|
||||
|
||||
return output
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
# If we add unicode_literals, Python 2.6.1 (required for OS X 10.6) breaks.
|
||||
from __future__ import print_function
|
||||
|
||||
import platform
|
||||
import sys
|
||||
|
|
|
@ -119,7 +119,7 @@ class OSXBootstrapper(BaseBootstrapper):
|
|||
# Once Xcode is installed, you need to agree to the license before you can
|
||||
# use it.
|
||||
try:
|
||||
output = subprocess.check_output(['/usr/bin/xcrun', 'clang'],
|
||||
output = self.check_output(['/usr/bin/xcrun', 'clang'],
|
||||
stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
if 'license' in e.output:
|
||||
|
@ -135,7 +135,7 @@ class OSXBootstrapper(BaseBootstrapper):
|
|||
print(INSTALL_XCODE_COMMAND_LINE_TOOLS_STEPS)
|
||||
sys.exit(1)
|
||||
|
||||
output = subprocess.check_output(['/usr/bin/clang', '--version'])
|
||||
output = self.check_output(['/usr/bin/clang', '--version'])
|
||||
match = RE_CLANG_VERSION.search(output)
|
||||
if match is None:
|
||||
raise Exception('Could not determine Clang version.')
|
||||
|
@ -170,7 +170,7 @@ class OSXBootstrapper(BaseBootstrapper):
|
|||
brew = self.which('brew')
|
||||
assert brew is not None
|
||||
|
||||
installed = subprocess.check_output([brew, 'list']).split()
|
||||
installed = self.check_output([brew, 'list']).split()
|
||||
|
||||
if 'python' not in installed:
|
||||
self.ensure_xquartz()
|
||||
|
|
Загрузка…
Ссылка в новой задаче