зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1720925: Move platform-specific Python upgrade instructions r=ahal
There's a "minimum Python check" that happens when Mach bootstraps that makes the bootstrap command's check obsolete. Since we want to use modern Python features throughout Mach, we need to move Python-out-of-date logic up to the front of the process. We're duplicating the OS-detection logic a bit, but now we regain per-platform Python instructions. Differential Revision: https://phabricator.services.mozilla.com/D120093
This commit is contained in:
Родитель
210af29ab0
Коммит
83721fed8d
|
@ -166,14 +166,47 @@ def mach_sys_path(mozilla_dir):
|
|||
]
|
||||
|
||||
|
||||
INSTALL_PYTHON_GUIDANCE_LINUX = """
|
||||
See https://firefox-source-docs.mozilla.org/setup/linux_build.html#installingpython
|
||||
for guidance on how to install Python on your system.
|
||||
""".strip()
|
||||
|
||||
INSTALL_PYTHON_GUIDANCE_OSX = """
|
||||
See https://firefox-source-docs.mozilla.org/setup/macos_build.html
|
||||
for guidance on how to prepare your system to build Firefox. Perhaps
|
||||
you need to update Xcode, or install Python using brew?
|
||||
""".strip()
|
||||
|
||||
INSTALL_PYTHON_GUIDANCE_MOZILLABUILD = """
|
||||
Python is provided by MozillaBuild; ensure your MozillaBuild
|
||||
installation is up to date.
|
||||
See https://firefox-source-docs.mozilla.org/setup/windows_build.html#install-mozillabuild
|
||||
for details.
|
||||
""".strip()
|
||||
|
||||
INSTALL_PYTHON_GUIDANCE_OTHER = """
|
||||
We do not have specific instructions for your platform on how to
|
||||
install Python. You may find Pyenv (https://github.com/pyenv/pyenv)
|
||||
helpful, if your system package manager does not provide a way to
|
||||
install a recent enough Python 3.
|
||||
""".strip()
|
||||
|
||||
|
||||
def bootstrap(topsrcdir):
|
||||
# Ensure we are running Python 2.7 or 3.5+. We put this check here so we
|
||||
# generate a user-friendly error message rather than a cryptic stack trace
|
||||
# on module import.
|
||||
# Ensure we are running Python 3.6+. We run this check as soon as
|
||||
# possible to avoid a cryptic import/usage error.
|
||||
major = sys.version_info[:2][0]
|
||||
if sys.version_info < (3, 6):
|
||||
print("Python 3.6+ is required to run mach.")
|
||||
print("You are running Python", platform.python_version())
|
||||
if sys.platform.startswith("linux"):
|
||||
print(INSTALL_PYTHON_GUIDANCE_LINUX)
|
||||
elif sys.platform.startswith("darwin"):
|
||||
print(INSTALL_PYTHON_GUIDANCE_OSX)
|
||||
elif "MOZILLABUILD" in os.environ:
|
||||
print(INSTALL_PYTHON_GUIDANCE_MOZILLABUILD)
|
||||
else:
|
||||
print(INSTALL_PYTHON_GUIDANCE_OTHER)
|
||||
sys.exit(1)
|
||||
|
||||
# This directory was deleted in bug 1666345, but there may be some ignored
|
||||
|
|
|
@ -6,7 +6,6 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||
|
||||
import hashlib
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -143,7 +142,6 @@ ac_add_options --enable-application=js
|
|||
# This should match the OLDEST_NON_LEGACY_VERSION in
|
||||
# version-control-tools/hgext/configwizard/__init__.py.
|
||||
MODERN_MERCURIAL_VERSION = LooseVersion("4.9")
|
||||
MODERN_PYTHON_VERSION = LooseVersion("3.6.0")
|
||||
|
||||
# Upgrade rust older than this.
|
||||
MODERN_RUST_VERSION = LooseVersion(MINIMUM_RUST_VERSION)
|
||||
|
@ -155,13 +153,6 @@ MODERN_NASM_VERSION = LooseVersion("2.14")
|
|||
class BaseBootstrapper(object):
|
||||
"""Base class for system bootstrappers."""
|
||||
|
||||
INSTALL_PYTHON_GUIDANCE = (
|
||||
"We do not have specific instructions for your platform on how to "
|
||||
"install Python. You may find Pyenv (https://github.com/pyenv/pyenv) "
|
||||
"helpful, if your system package manager does not provide a way to "
|
||||
"install a recent enough Python 3 and 2."
|
||||
)
|
||||
|
||||
def __init__(self, no_interactive=False, no_system_changes=False):
|
||||
self.package_manager_updated = False
|
||||
self.no_interactive = no_interactive
|
||||
|
@ -643,19 +634,6 @@ class BaseBootstrapper(object):
|
|||
"""
|
||||
print(MERCURIAL_UNABLE_UPGRADE % (current, MODERN_MERCURIAL_VERSION))
|
||||
|
||||
def ensure_python_modern(self):
|
||||
version = LooseVersion(platform.python_version())
|
||||
if version >= MODERN_PYTHON_VERSION:
|
||||
print("Your version of Python (%s) is new enough." % version)
|
||||
else:
|
||||
print(
|
||||
"ERROR: Your version of Python (%s) is not new enough. You "
|
||||
"must have Python >= %s to build Firefox."
|
||||
% (version, MODERN_PYTHON_VERSION)
|
||||
)
|
||||
print(self.INSTALL_PYTHON_GUIDANCE)
|
||||
sys.exit(1)
|
||||
|
||||
def warn_if_pythonpath_is_set(self):
|
||||
if "PYTHONPATH" in os.environ:
|
||||
print(
|
||||
|
|
|
@ -325,10 +325,6 @@ class Bootstrapper(object):
|
|||
|
||||
self.instance.warn_if_pythonpath_is_set()
|
||||
|
||||
# This doesn't affect any system state and we'd like to bail out as soon
|
||||
# as possible if this check fails.
|
||||
self.instance.ensure_python_modern()
|
||||
|
||||
state_dir = self.create_state_dir()
|
||||
self.instance.state_dir = state_dir
|
||||
|
||||
|
|
|
@ -163,12 +163,5 @@ class LinuxBootstrapper(
|
|||
StyloInstall,
|
||||
WasiSysrootInstall,
|
||||
):
|
||||
|
||||
INSTALL_PYTHON_GUIDANCE = (
|
||||
"See https://firefox-source-docs.mozilla.org/setup/linux_build.html"
|
||||
"#installingpython for guidance on how to install Python on your "
|
||||
"system."
|
||||
)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
|
|
|
@ -109,11 +109,6 @@ def is_windefender_affecting_srcdir(srcdir):
|
|||
class MozillaBuildBootstrapper(BaseBootstrapper):
|
||||
"""Bootstrapper for MozillaBuild to install rustup."""
|
||||
|
||||
INSTALL_PYTHON_GUIDANCE = (
|
||||
"Python is provided by MozillaBuild; ensure your MozillaBuild "
|
||||
"installation is up to date."
|
||||
)
|
||||
|
||||
def __init__(self, no_interactive=False, no_system_changes=False):
|
||||
BaseBootstrapper.__init__(
|
||||
self, no_interactive=no_interactive, no_system_changes=no_system_changes
|
||||
|
|
|
@ -121,13 +121,6 @@ class OSXBootstrapperLight(BaseBootstrapper):
|
|||
|
||||
|
||||
class OSXBootstrapper(BaseBootstrapper):
|
||||
|
||||
INSTALL_PYTHON_GUIDANCE = (
|
||||
"See https://firefox-source-docs.mozilla.org/setup/macos_build.html "
|
||||
"for guidance on how to prepare your system to build Firefox. Perhaps "
|
||||
"you need to update Xcode, or install Python using brew?"
|
||||
)
|
||||
|
||||
def __init__(self, version, **kwargs):
|
||||
BaseBootstrapper.__init__(self, **kwargs)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче