зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
a6367adcc2
Коммит
af94e85e8d
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче