Bug 1633039 - Don't check for Python 2 in configure r=glandium

Differential Revision: https://phabricator.services.mozilla.com/D72895
This commit is contained in:
Ricky Stewart 2020-05-05 16:02:02 +00:00
parent 56c10c5aa2
commit 0015091b18
5 changed files with 3 additions and 111 deletions

View File

@ -168,7 +168,7 @@ task machBuildFaster(type: MachExec) {
workingDir "${topsrcdir}"
commandLine mozconfig.substs.PYTHON
commandLine mozconfig.substs.PYTHON3
args "${topsrcdir}/mach"
args 'build'
args 'faster'

View File

@ -470,113 +470,6 @@ def mozconfig_options(mozconfig, automation, help):
add(key, value)
# Python 2
# ========
option(env='PYTHON', nargs=1, help='Python 2.7 interpreter')
@depends('PYTHON', check_build_environment, 'MOZILLABUILD')
@imports(_from='__builtin__', _import='Exception')
@imports(_from='mozbuild.configure.util', _import='LineIO')
@imports(_from='mozbuild.virtualenv', _import='VirtualenvManager')
@imports(_from='mozbuild.virtualenv', _import='verify_python_version')
@imports(_from='mozbuild.pythonutil', _import='find_python2_executable')
@imports(_from='mozbuild.pythonutil', _import='python_executable_version')
@imports(_from='six', _import='ensure_text')
def virtualenv_python2(env_python, build_env, mozillabuild):
# Verify that the Python version we executed this code with is the minimum
# required version to handle all project code.
with LineIO(lambda l: log.error(l)) as out:
verify_python_version(out)
python = env_python[0] if env_python else None
log.debug("python2: executable from configuration: %r" % python)
# If this is a mozilla-central build, we'll find the virtualenv in the top
# source directory. If this is a SpiderMonkey build, we assume we're at
# js/src and try to find the virtualenv from the mozilla-central root.
# See mozilla-central changeset d2cce982a7c809815d86d5daecefe2e7a563ecca
# Bug 784841
topsrcdir, topobjdir = build_env.topsrcdir, build_env.topobjdir
if topobjdir.endswith('/js/src'):
topobjdir = topobjdir[:-7]
# If we know the Python executable the caller is asking for then verify its
# version. If the caller did not ask for a specific executable then find
# a reasonable default.
if python:
try:
version = python_executable_version(python).version
except Exception as e:
raise FatalCheckError('could not determine version of PYTHON '
'(%s): %s' % (python, e))
elif mozillabuild:
# MozillaBuild provides a Python 2.
python = normsep('%s/python/python2.exe' % mozillabuild)
try:
version = python_executable_version(python).version
except Exception as e:
raise FatalCheckError('could not determine version of '
'MozillaBuild python: %s' % e)
else:
# Fall back to the search routine.
python, version = find_python2_executable()
# The API returns a bytes whereas everything in configure is unicode.
if python:
python = ensure_text(python)
if not python:
raise FatalCheckError('Python 2.7 is required to build. '
'Ensure a `python2.7` executable is in your '
'PATH or define PYTHON to point to a Python '
'2.7 executable.')
if version < (2, 7, 0):
raise FatalCheckError('Python 2.7 required to build; '
'%s is Python %d.%d' % (python, version[0],
version[1]))
log.debug("python2: found executable: %r" % python)
virtualenvs_root = os.path.join(topobjdir, '_virtualenvs')
with LineIO(lambda l: log.info(l), 'replace') as out:
manager = VirtualenvManager(
topsrcdir, topobjdir,
os.path.join(virtualenvs_root, 'init'), out,
os.path.join(topsrcdir, 'build', 'virtualenv_packages.txt'))
log.debug("python: using venv: %r" % manager.virtualenv_root)
if not manager.up_to_date(python):
log.info('Creating Python 2 environment')
manager.build(python)
else:
log.debug("python2: venv is up to date")
python = normsep(manager.python_path)
str_version = '.'.join(str(v) for v in version)
return namespace(
path=python,
version=version,
str_version=str_version,
)
@depends(virtualenv_python2)
@checking('for Python 2', callback=lambda x: '%s (%s)' % (x.path, x.str_version))
def virtualenv_python2(venv):
return venv
set_config('PYTHON', virtualenv_python2.path)
add_old_configure_assignment('PYTHON', virtualenv_python2.path)
# Source checkout and version control integration.
# ================================================

View File

@ -580,7 +580,7 @@ if args.variant == 'msan':
# Generate stacks from minidumps.
if use_minidump:
venv_python = os.path.join(OBJDIR, "_virtualenvs", "init", "bin", "python")
venv_python = os.path.join(OBJDIR, "_virtualenvs", "init_py3", "bin", "python3")
run_command([
venv_python,
os.path.join(DIR.source, "testing/mozbase/mozcrash/mozcrash/mozcrash.py"),

View File

@ -171,7 +171,6 @@ class FasterMakeBackend(MakeBackend, PartialBackend):
# Add a few necessary variables inherited from configure
for var in (
'PYTHON',
'PYTHON3',
'ACDEFINES',
'MOZ_BUILD_APP',

View File

@ -15,6 +15,6 @@ import subprocess
def main(output, *inputs):
env = dict(os.environ)
env['PERL'] = str(buildconfig.substs['PERL'])
output.write(subprocess.check_output([buildconfig.substs['PYTHON'],
output.write(subprocess.check_output([buildconfig.substs['PYTHON3'],
inputs[0], inputs[2]], env=env))
return None