зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1759329: Properly exclude Brew's site-packages when using Mach venv r=ahal
Previously, when trying to determine the minimal `sys.path` that just includes the standard library (but no `pip`-installed packages), we would resolve the `sys.path` and remove the system and user site-packages. However, this "removal" step didn't work as-is for `brew`'s Python, because its "system site-packages" is //different// from its `site.getsitepackages()`. Stepping back though, there's an easier solution: run `python` with the `-S` flag, and no "site" paths or custom initialization logic will add anything extra to the stdlib. Differential Revision: https://phabricator.services.mozilla.com/D141508
This commit is contained in:
Родитель
c14c6bb509
Коммит
9653ddb59b
|
@ -946,14 +946,12 @@ class ExternalPythonSite:
|
|||
stdlib_paths = subprocess.check_output(
|
||||
[
|
||||
self.python_path,
|
||||
# Don't "import site", so we don't include system/user pip-installed
|
||||
# packages.
|
||||
"-S",
|
||||
"-c",
|
||||
"import sys; import site; "
|
||||
"site_packages = [site.getusersitepackages()] + site.getsitepackages(); "
|
||||
"print([path for path in sys.path if path not in site_packages])",
|
||||
"import sys; print(sys.path)",
|
||||
],
|
||||
# The "site" module may return erroneous entries for the system python
|
||||
# if the "VIRTUAL_ENV" environment variable is set.
|
||||
env={k: v for k, v in os.environ.items() if k != "VIRTUAL_ENV"},
|
||||
universal_newlines=True,
|
||||
)
|
||||
return ast.literal_eval(stdlib_paths)
|
||||
|
|
Загрузка…
Ссылка в новой задаче