Open mharbison72 opened 3 years ago
This is already implemented via the PythonInterpreterConfig.user_site_directory
attribute exposed to Starlark.
What am I missing here?
I missed that somehow, but it doesn't seem to work.
diff --git a/rust/hgcli/pyoxidizer.bzl b/rust/hgcli/pyoxidizer.bzl
--- a/rust/hgcli/pyoxidizer.bzl
+++ b/rust/hgcli/pyoxidizer.bzl
@@ -44,19 +44,6 @@ if extra_path is not None:
# 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
- appdata = os.environ.get('APPDATA')
- if appdata:
- sys.path.append(
- os.path.join(
- appdata,
- 'Python',
- 'Python%d%d' % (vi[0], vi[1]),
- 'site-packages',
- )
- )
import hgdemandimport;
hgdemandimport.enable();
from mercurial import dispatch;
@@ -111,6 +98,9 @@ def make_exe(dist):
# We want to let the user load extensions from the file system
config.filesystem_importer = True
+ # Load `pip install --user` extensions
+ config.user_site_directory = True
+
# We need this to make resourceutil happy, since it looks for sys.frozen.
config.sys_frozen = True
config.legacy_windows_stdio = True
The evolve extension doesn't load (as it did with the removed manual extension of sys.path
), and print(sys.flags)
from inside the debugshell
command of the binary generated with this diff still prints "no_user_site=1, no_site=0".
It looks like this is what disables looking in the user site package. The only reference to this variable is in a test checking that it is 1, so it's evidently on purpose. However, it would be useful to make the user site available for loading Mercurial extensions. The py2 builds already look there, so not having this is a bit of a regression.