# HG changeset patch # User Matt Harbison # Date 1629338395 14400 # Node ID 95af358fcdfe12e2241f52575a143a8c7efac10e # Parent ad2c37075f46ed9f1134b97b96f816c6bef50cd9 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 diff -r ad2c37075f46 -r 95af358fcdfe rust/hgcli/pyoxidizer.bzl --- 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;