Bug 1675675 - Only put mach_bootstrap paths in PYTHONPATH for mach python --no-virtualenv. r=firefox-build-system-reviewers,rstewart

With PYTHONPATH containing other directories, such as the python ones,
bad things can happen when the python script that is being run then
goes on to subprocess.Popen a python process for a different virtualenv,
or a different version, or whatever.

Differential Revision: https://phabricator.services.mozilla.com/D96155
This commit is contained in:
Mike Hommey 2020-11-06 17:30:58 +00:00
Родитель a6367adcc2
Коммит af94e85e8d
2 изменённых файлов: 11 добавлений и 5 удалений

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

@ -177,6 +177,13 @@ def search_path(mozilla_dir, packages_txt):
yield path
def mach_sys_path(mozilla_dir):
return [
os.path.join(mozilla_dir, path)
for path in search_path(mozilla_dir, "build/mach_virtualenv_packages.txt")
]
def bootstrap(topsrcdir, mozilla_dir=None):
if mozilla_dir is None:
mozilla_dir = topsrcdir
@ -198,10 +205,7 @@ def bootstrap(topsrcdir, mozilla_dir=None):
# case. For default behavior, we educate users and give them an opportunity
# to react. We always exit after creating the directory because users don't
# like surprises.
sys.path[0:0] = [
os.path.join(mozilla_dir, path)
for path in search_path(mozilla_dir, "build/mach_virtualenv_packages.txt")
]
sys.path[0:0] = mach_sys_path(mozilla_dir)
import mach.base
import mach.main
from mach.util import setenv

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

@ -61,8 +61,10 @@ class MachCommands(MachCommandBase):
}
if no_virtualenv:
from mach_bootstrap import mach_sys_path
python_path = sys.executable
append_env["PYTHONPATH"] = os.pathsep.join(sys.path)
append_env["PYTHONPATH"] = os.pathsep.join(mach_sys_path(self.topsrcdir))
else:
self.activate_virtualenv()
python_path = self.virtualenv_manager.python_path