hg: don't attempt to extend `sys.path` with the user site without `APPDATA`
This variable is created by the system and *should* be available, but
test-lfs-bundle.t has a test where it is explicitly unset. It wasn't caught
before because prior to 95af358fcdfe, it was limited to the py2exe binary. As a
precaution, fix both that and the pyoxidizer case that was causing the test to
fail.
Differential Revision: https://phab.mercurial-scm.org/D11354
--- a/hg Thu Aug 26 09:49:09 2021 +0200
+++ b/hg Thu Aug 26 11:04:14 2021 -0400
@@ -28,14 +28,16 @@
# to the documentation.
if getattr(sys, 'frozen', None) == 'console_exe':
vi = sys.version_info
- sys.path.append(
- os.path.join(
- os.environ['APPDATA'],
- 'Python',
- 'Python%d%d' % (vi[0], vi[1]),
- 'site-packages',
+ appdata = os.environ.get('APPDATA')
+ if appdata:
+ sys.path.append(
+ os.path.join(
+ appdata,
+ 'Python',
+ 'Python%d%d' % (vi[0], vi[1]),
+ 'site-packages',
+ )
)
- )
from hgdemandimport import tracing
--- a/rust/hgcli/pyoxidizer.bzl Thu Aug 26 09:49:09 2021 +0200
+++ b/rust/hgcli/pyoxidizer.bzl Thu Aug 26 11:04:14 2021 -0400
@@ -47,14 +47,16 @@
# 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',
+ 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;