changeset 47857:95af358fcdfe stable

pyoxidizer: add user-site to `sys.path` on Windows This is a port of 53221078e0de to Windows to allow pip-installed extensions to be loaded without specifying a path. It's a major headache to have an hg.exe on `PATH` that needs to have the path to the extensions specified, because WSL doesn't see the same path. This is only for Windows for now, to match the currently shipping py2 behavior. There is a better solution with using the `site` package, but this needs support in PyOxidizer[1]. [1] https://github.com/indygreg/PyOxidizer/issues/430 Differential Revision: https://phab.mercurial-scm.org/D11308
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 18 Aug 2021 21:59:55 -0400
parents ad2c37075f46
children 4162f6b40f2c
files rust/hgcli/pyoxidizer.bzl
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hgcli/pyoxidizer.bzl	Wed Aug 18 14:58:42 2021 -0400
+++ b/rust/hgcli/pyoxidizer.bzl	Wed Aug 18 21:59:55 2021 -0400
@@ -44,6 +44,17 @@
     # 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))
+# Add user site to sys.path to load extensions without the full path
+if os.name == 'nt':
+    vi = sys.version_info
+    sys.path.append(
+        os.path.join(
+            os.environ['APPDATA'],
+            'Python',
+            'Python%d%d' % (vi[0], vi[1]),
+            'site-packages',
+        )
+    )
 import hgdemandimport;
 hgdemandimport.enable();
 from mercurial import dispatch;