From 16b857cec155f899c0960a883b17fc56647ec7e6 Mon Sep 17 00:00:00 2001 From: Mitchell Hentges Date: Tue, 20 Jul 2021 21:42:03 +0000 Subject: [PATCH] Bug 1717051: Only use stdlib for installing pip packages r=ahal `_install_pip_package()` may be run from `populate()`, which is invoked from a child Python process that doesn't have in-tree Python modules in its sys.path. An alternate solution would be to add in-tree modules to the sys.path, but that seemed more costly than simply using `tempfile` and `shutil`. Differential Revision: https://phabricator.services.mozilla.com/D119834 --- python/mozbuild/mozbuild/virtualenv.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/python/mozbuild/mozbuild/virtualenv.py b/python/mozbuild/mozbuild/virtualenv.py index 0afd1eccba96..934717878297 100644 --- a/python/mozbuild/mozbuild/virtualenv.py +++ b/python/mozbuild/mozbuild/virtualenv.py @@ -14,6 +14,7 @@ import platform import shutil import subprocess import sys +from tempfile import TemporaryDirectory IS_NATIVE_WIN = sys.platform == "win32" and os.sep == "\\" IS_CYGWIN = sys.platform == "cygwin" @@ -437,9 +438,6 @@ class VirtualenvManager(VirtualenvHelper): If vendored is True, no package index will be used and no dependencies will be installed. """ - import mozfile - from mozfile import TemporaryDirectory - if sys.executable.startswith(self.bin_path): # If we're already running in this interpreter, we can optimize in # the case that the package requirement is already satisfied. @@ -482,7 +480,7 @@ class VirtualenvManager(VirtualenvHelper): tmp, "{}-1.0-py3-none-any.whl".format(os.path.basename(package)) ) shutil.make_archive(wheel_file, "zip", package) - mozfile.move("{}.zip".format(wheel_file), wheel_file) + shutil.move("{}.zip".format(wheel_file), wheel_file) package = wheel_file args.append(package)