Backed out changeset 894fc83e19a0 (bug 1717051) for causing busting macth commands. a=backout

This commit is contained in:
criss 2021-09-30 10:36:36 +03:00
Родитель 33a743b9b9
Коммит 16f898657c
8 изменённых файлов: 36 добавлений и 39 удалений

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

@ -73,7 +73,7 @@ to just keep them separate so there is no potential for conflicts.
Very early in the build process, a virtualenv is created inside the
:term:`object directory`. The virtualenv is configured such that it can
find all the Python packages in the source tree. The code for this lives
in :py:mod:`mach.virtualenv`.
in :py:mod:`mozbuild.virtualenv`.
Deficiencies
------------

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

@ -187,7 +187,6 @@ def _activate_python_environment(topsrcdir):
]
from mach.requirements import MachEnvRequirements
from mach.virtualenv import MozVirtualenvMetadata
thunderbird_dir = os.path.join(topsrcdir, "comm")
is_thunderbird = os.path.exists(thunderbird_dir) and bool(
@ -201,8 +200,6 @@ def _activate_python_environment(topsrcdir):
os.path.join(topsrcdir, "build", "mach_virtualenv_packages.txt"),
)
active_metadata = MozVirtualenvMetadata.from_runtime()
is_mach_virtualenv = active_metadata and active_metadata.virtualenv_name == "mach"
if os.environ.get("MACH_USE_SYSTEM_PYTHON") or os.environ.get("MOZ_AUTOMATION"):
env_var = (
"MOZ_AUTOMATION"
@ -255,21 +252,16 @@ def _activate_python_environment(topsrcdir):
# (optional) dependencies are not installed.
_scrub_system_site_packages()
sys.path[0:0] = [
os.path.join(topsrcdir, pth.path)
for pth in requirements.pth_requirements
+ requirements.vendored_requirements
]
elif not is_mach_virtualenv:
# We're in an environment where we normally *would* use the Mach virtualenv,
elif sys.prefix == sys.base_prefix:
# We're in an environment where we normally use the Mach virtualenv,
# but we're running a "nativecmd" such as "create-mach-environment".
# Remove global site packages from sys.path to improve isolation accordingly.
_scrub_system_site_packages()
sys.path[0:0] = [
os.path.join(topsrcdir, pth.path)
for pth in requirements.pth_requirements
+ requirements.vendored_requirements
]
sys.path[0:0] = [
os.path.join(topsrcdir, pth.path)
for pth in requirements.pth_requirements + requirements.vendored_requirements
]
def initialize(topsrcdir):

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

@ -226,8 +226,8 @@ option(env="PYTHON3", nargs=1, help="Python 3 interpreter (3.6 or later)")
@imports("subprocess")
@imports("distutils.sysconfig")
@imports(_from="mozbuild.configure.util", _import="LineIO")
@imports(_from="mach.virtualenv", _import="VirtualenvManager")
@imports(_from="mach.virtualenv", _import="verify_python_version")
@imports(_from="mozbuild.virtualenv", _import="VirtualenvManager")
@imports(_from="mozbuild.virtualenv", _import="verify_python_version")
@imports(_from="mozbuild.pythonutil", _import="find_python3_executable")
@imports(_from="mozbuild.pythonutil", _import="python_executable_version")
@imports(_from="six", _import="ensure_text")

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

@ -10,7 +10,7 @@ import platform
import subprocess
from subprocess import CalledProcessError
from mach.virtualenv import VirtualenvHelper
from mozbuild.virtualenv import VirtualenvHelper
from mozfile import which

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

@ -289,7 +289,7 @@ class MozbuildObject(ProcessExecutionMixin):
@property
def virtualenv_manager(self):
from mach.virtualenv import VirtualenvManager
from .virtualenv import VirtualenvManager
if self._virtualenv_manager is None:
self._virtualenv_manager = VirtualenvManager(

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

@ -2446,7 +2446,7 @@ def package_l10n(command_context, verbose=False, locales=[]):
def create_mach_environment(command_context, force=False):
"""Create the mach virtualenv."""
from mozboot.util import get_mach_virtualenv_root
from mach.virtualenv import VirtualenvManager
from mozbuild.virtualenv import VirtualenvManager
virtualenv_path = get_mach_virtualenv_root()
if sys.executable.startswith(virtualenv_path):
@ -2461,6 +2461,7 @@ def create_mach_environment(command_context, force=False):
command_context.topsrcdir,
os.path.dirname(virtualenv_path),
"mach",
populate_local_paths=False,
)
if manager.up_to_date() and not force:

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

@ -198,7 +198,7 @@ class MozbuildSymbols(Directive):
def setup(app):
from mach.virtualenv import VirtualenvManager
from mozbuild.virtualenv import VirtualenvManager
from moztreedocs import manager
app.add_directive("mozbuildsymbols", MozbuildSymbols)

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

@ -55,10 +55,6 @@ class MozVirtualenvMetadata:
and self.virtualenv_name == other.virtualenv_name
)
@classmethod
def from_runtime(cls):
return cls.from_path(os.path.join(sys.prefix, METADATA_FILENAME))
@classmethod
def from_path(cls, path):
try:
@ -108,6 +104,7 @@ class VirtualenvManager(VirtualenvHelper):
virtualenvs_dir,
virtualenv_name,
*,
populate_local_paths=True,
log_handle=sys.stdout,
base_python=sys.executable,
manifest_path=None,
@ -133,6 +130,7 @@ class VirtualenvManager(VirtualenvHelper):
self.exe_info_path = os.path.join(self.virtualenv_root, "python_exe.txt")
self.log_handle = log_handle
self.populate_local_paths = populate_local_paths
self._virtualenv_name = virtualenv_name
self._manifest_path = manifest_path or os.path.join(
topsrcdir, "build", f"{virtualenv_name}_virtualenv_packages.txt"
@ -207,7 +205,9 @@ class VirtualenvManager(VirtualenvHelper):
if existing_metadata != self._metadata:
return False
if env_requirements.pth_requirements or env_requirements.vendored_requirements:
if (
env_requirements.pth_requirements or env_requirements.vendored_requirements
) and self.populate_local_paths:
try:
with open(
os.path.join(self._site_packages_dir(), PTH_FILENAME)
@ -350,18 +350,19 @@ class VirtualenvManager(VirtualenvHelper):
del os.environ[k]
env_requirements = self._requirements()
python_lib = distutils.sysconfig.get_python_lib()
with open(os.path.join(python_lib, PTH_FILENAME), "a") as f:
for pth_requirement in (
env_requirements.pth_requirements
+ env_requirements.vendored_requirements
):
path = os.path.join(self.topsrcdir, pth_requirement.path)
# This path is relative to the .pth file. Using a
# relative path allows the srcdir/objdir combination
# to be moved around (as long as the paths relative to
# each other remain the same).
f.write("{}\n".format(os.path.relpath(path, python_lib)))
if self.populate_local_paths:
python_lib = distutils.sysconfig.get_python_lib()
with open(os.path.join(python_lib, PTH_FILENAME), "a") as f:
for pth_requirement in (
env_requirements.pth_requirements
+ env_requirements.vendored_requirements
):
path = os.path.join(self.topsrcdir, pth_requirement.path)
# This path is relative to the .pth file. Using a
# relative path allows the srcdir/objdir combination
# to be moved around (as long as the paths relative to
# each other remain the same).
f.write("{}\n".format(os.path.relpath(path, python_lib)))
for pypi_requirement in env_requirements.pypi_requirements:
self.install_pip_package(str(pypi_requirement.requirement))
@ -406,6 +407,8 @@ class VirtualenvManager(VirtualenvHelper):
self._virtualenv_name,
self._manifest_path,
]
if self.populate_local_paths:
args.append("--populate-local-paths")
result = self._log_process_output(args, cwd=self.topsrcdir)
@ -603,6 +606,7 @@ if __name__ == "__main__":
opts.topsrcdir,
opts.virtualenvs_dir,
opts.virtualenv_name,
populate_local_paths=opts.populate_local_paths,
manifest_path=opts.manifest_path,
)