[Request] [+ ] D11452: pyoxidizer: add the user site to `sys.path` on macOS
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Fri Sep 17 21:01:31 UTC 2021
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This allows 3rd party extensions that are installed with `pip` to be picked up,
similar to what we do on Windows. PyOxidizer has a bug that prevents this from
working without this extra help (see 95af358fcdfe <https://phab.mercurial-scm.org/rHG95af358fcdfe12e2241f52575a143a8c7efac10e>), though it appears there's
another wrinkle here with `sys._framework` too.
I needed this to see if the problem[1] loading the keyring extension on Windows
also occurs on macOS (it doesn't).
[1] https://github.com/indygreg/PyOxidizer/issues/445
REPOSITORY
rHG Mercurial
BRANCH
stable
REVISION DETAIL
https://phab.mercurial-scm.org/D11452
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
@@ -58,6 +58,20 @@
'site-packages',
)
)
+elif sys.platform == "darwin":
+ vi = sys.version_info
+
+ def joinuser(*args):
+ return os.path.expanduser(os.path.join(*args))
+
+ # Note: site.py uses `sys._framework` instead of hardcoding "Python" as the
+ # 3rd arg, but that is set to an empty string in an oxidized binary. It
+ # has a fallback to ~/.local when `sys._framework` isn't set, but we want
+ # to match what the system python uses, so it sees pip installed stuff.
+ usersite = joinuser("~", "Library", "Python",
+ "%d.%d" % vi[:2], "lib/python/site-packages")
+
+ sys.path.append(usersite)
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/20210917/1d586681/attachment.html>
More information about the Mercurial-patches
mailing list