[Request] [+ ] D11308: pyoxidizer: add user-site to `sys.path` on Windows
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Thu Aug 19 02:47:37 UTC 2021
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This is a port of 53221078e0de <https://phab.mercurial-scm.org/rHG53221078e0de65d1a821ce5311dec45a7a978301> 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
REPOSITORY
rHG Mercurial
BRANCH
stable
REVISION DETAIL
https://phab.mercurial-scm.org/D11308
AFFECTED FILES
rust/hgcli/pyoxidizer.bzl
CHANGE DETAILS
diff --git a/rust/hgcli/pyoxidizer.bzl b/rust/hgcli/pyoxidizer.bzl
--- a/rust/hgcli/pyoxidizer.bzl
+++ b/rust/hgcli/pyoxidizer.bzl
@@ -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;
To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210819/c517f961/attachment.html>
More information about the Mercurial-patches
mailing list