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
This commit is contained in:
Mitchell Hentges 2021-07-20 21:42:03 +00:00
Родитель ff3f9b87f4
Коммит 16b857cec1
1 изменённых файлов: 2 добавлений и 4 удалений

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

@ -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)