depot/third_party/nixpkgs/pkgs/development/python-modules/glean-sdk/fix-spawned-process-environment.patch
Default email ce641f4048 Project import generated by Copybara.
GitOrigin-RevId: bc5d68306b40b8522ffb69ba6cff91898c2fbbff
2021-12-06 17:07:01 +01:00

20 lines
950 B
Diff

diff --git a/glean-core/python/glean/_process_dispatcher.py b/glean-core/python/glean/_process_dispatcher.py
index 33a8b12796..a39b54a917 100644
--- a/glean-core/python/glean/_process_dispatcher.py
+++ b/glean-core/python/glean/_process_dispatcher.py
@@ -120,8 +120,14 @@ def dispatch(cls, func, args) -> Union[_SyncWorkWrapper, subprocess.Popen]:
Path(".coveragerc").absolute()
)
+ # Explicitly pass the contents of `sys.path` as `PYTHONPATH` to the
+ # subprocess so that there aren't any module search path
+ # differences.
+ python_path = ":".join(sys.path)[1:]
+
p = subprocess.Popen(
- [sys.executable, _process_dispatcher_helper.__file__, payload]
+ [sys.executable, _process_dispatcher_helper.__file__, payload],
+ env={"PYTHONPATH": python_path},
)
cls._last_process = p