Bug 1717051: Move arm64 rosetta check to bootstrap r=firefox-build-system-reviewers,glandium

It was originally added to "create-mach-environment" because that would
eventually be called by "./mach bootstrap".
However, as "create-mach-environment" is going away, this moves it
closer to the command that it's meant to impact.

Differential Revision: https://phabricator.services.mozilla.com/D120399
This commit is contained in:
Mitchell Hentges 2021-09-03 20:46:23 +00:00
Родитель ef3a0ed88c
Коммит d9613ed9e7
2 изменённых файлов: 22 добавлений и 22 удалений

Просмотреть файл

@ -337,6 +337,28 @@ class Bootstrapper(object):
self.instance.warn_if_pythonpath_is_set()
if sys.platform.startswith("darwin") and not os.environ.get(
"MACH_I_DO_WANT_TO_USE_ROSETTA"
):
# If running on arm64 mac, check whether we're running under
# Rosetta and advise against it.
proc = subprocess.run(
["sysctl", "-n", "sysctl.proc_translated"],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
)
if (
proc.returncode == 0
and proc.stdout.decode("ascii", "replace").strip() == "1"
):
print(
"Python is being emulated under Rosetta. Please use a native "
"Python instead. If you still really want to go ahead, set "
"the MACH_I_DO_WANT_TO_USE_ROSETTA environment variable.",
file=sys.stderr,
)
return 1
state_dir = self.create_state_dir()
self.instance.state_dir = state_dir

Просмотреть файл

@ -2454,28 +2454,6 @@ class CreateMachEnvironment(MachCommandBase):
from mozboot.util import get_mach_virtualenv_root
from mozbuild.virtualenv import VirtualenvManager
if sys.platform.startswith("darwin") and not os.environ.get(
"MACH_I_DO_WANT_TO_USE_ROSETTA"
):
# If running on arm64 mac, check whether we're running under
# Rosetta and advise against it.
proc = subprocess.run(
["sysctl", "-n", "sysctl.proc_translated"],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
)
if (
proc.returncode == 0
and proc.stdout.decode("ascii", "replace").strip() == "1"
):
print(
"Python is being emulated under Rosetta. Please use a native "
"Python instead. If you still really want to go ahead, set "
"the MACH_I_DO_WANT_TO_USE_ROSETTA environment variable.",
file=sys.stderr,
)
return 1
virtualenv_path = get_mach_virtualenv_root()
if sys.executable.startswith(virtualenv_path):
print(