Patchwork D11302: pyoxidizer: re-install PYTHONPATH behavior

login
register
mail settings
Submitter phabricator
Date Aug. 18, 2021, 4:21 p.m.
Message ID <differential-rev-PHID-DREV-vqunf2tcemsdaze3u2q3-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49616/
State Superseded
Headers show

Comments

phabricator - Aug. 18, 2021, 4:21 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D11302

AFFECTED FILES
  rust/hgcli/pyoxidizer.bzl

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hgcli/pyoxidizer.bzl b/rust/hgcli/pyoxidizer.bzl
--- a/rust/hgcli/pyoxidizer.bzl
+++ b/rust/hgcli/pyoxidizer.bzl
@@ -36,6 +36,12 @@ 
 
 # 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
+    sys.path[0:0] = extra_path.split(os.pathsep)
 import hgdemandimport;
 hgdemandimport.enable();
 from mercurial import dispatch;