pyoxidizer: re-install PYTHONPATH behavior stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 18 Aug 2021 21:37:55 +0200
branchstable
changeset 47850 b962a913ee3b
parent 47849 f07a00543396
child 47851 d88f4231712c
pyoxidizer: re-install PYTHONPATH behavior Hooks and extensions can rely on PYTHONPATH value. Yet the pyoxidized binary ignore the variable. So we manually reinstall the behavior to fix various tests and restore the expected behavior. This positively affects: - test-extension.t - test-hook.t Differential Revision: https://phab.mercurial-scm.org/D11302
rust/hgcli/pyoxidizer.bzl
--- a/rust/hgcli/pyoxidizer.bzl	Wed Aug 18 16:48:32 2021 +0200
+++ b/rust/hgcli/pyoxidizer.bzl	Wed Aug 18 21:37:55 2021 +0200
@@ -36,6 +36,14 @@
 
 # Code to run in Python interpreter.
 RUN_CODE = """
+import os
+import sys
+extra_path = os.environ.get('PYTHONPATH')
+if extra_path is not None:
+    # extensions and hooks expect a working python environment
+    # We do not prepend the values because the Mercurial library wants to be in
+    # the front of the sys.path to avoid picking up other installations.
+    sys.path.extend(extra_path.split(os.pathsep))
 import hgdemandimport;
 hgdemandimport.enable();
 from mercurial import dispatch;