diff --git a/tools/wpt/virtualenv.py b/tools/wpt/virtualenv.py index 1cfb1506cfb4b9..b20a928880209a 100644 --- a/tools/wpt/virtualenv.py +++ b/tools/wpt/virtualenv.py @@ -91,6 +91,13 @@ def working_set(self): return self._working_set def activate(self): + if sys.platform == 'darwin': + # The default Python on macOS sets a __PYVENV_LAUNCHER__ environment + # variable which affects invocation of python (e.g. via pip) in a + # virtualenv. Unset it if present to avoid this. More background: + # https://github.com/web-platform-tests/wpt/issues/27377 + # https://github.com/python/cpython/pull/9516 + os.environ.pop('__PYVENV_LAUNCHER__', None) path = os.path.join(self.bin_path, "activate_this.py") with open(path) as f: exec(f.read(), {"__file__": path})