python3Packages.glean-sdk: apply patch for process environments

This commit is contained in:
Dzmitry Malyshau
2021-11-18 09:37:48 -05:00
parent 51324da2e0
commit 34db549448
2 changed files with 27 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
, python3Packages
, rustPlatform
, setuptools-rust
, fetchpatch
}:
python3Packages.buildPythonPackage rec {
@@ -14,6 +15,12 @@ python3Packages.buildPythonPackage rec {
sha256 = "sha256-X2p6KQnEB6ZHdCHGFVEoEMiI+0R2vfGqel+jFKTcx74=";
};
patches = [
# Fix the environment for spawned process
# https://github.com/mozilla/glean/pull/1542
./pr-1542.patch
];
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
name = "${pname}-${version}";

View File

@@ -0,0 +1,20 @@
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