# HG changeset patch # User Matt Harbison # Date 2020-12-07 21:32:30 # Node ID 9e785d94052551c65f0dd15124b0927ec1a0add4 # Parent cc0b332ab9fc60aeda2a4b52b1ff8f5dd41376b1 run-tests: extend PATH on Windows to include user installed scripts This allows the test environment to see pylint.exe when installed with `pip install --user`, since it isn't normally on PATH. Differential Revision: https://phab.mercurial-scm.org/D9535 diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -3484,7 +3484,29 @@ class TestRunner(object): path = os.environ['PATH'].split(os.pathsep) while exedir in path: path.remove(exedir) - os.environ['PATH'] = os.pathsep.join([exedir] + path) + + # Binaries installed by pip into the user area like pylint.exe may + # not be in PATH by default. + extra_paths = [exedir] + vi = sys.version_info + if 'APPDATA' in os.environ: + scripts_dir = os.path.join( + os.environ['APPDATA'], + 'Python', + 'Python%d%d' % (vi[0], vi[1]), + 'Scripts', + ) + + if vi.major == 2: + scripts_dir = os.path.join( + os.environ['APPDATA'], + 'Python', + 'Scripts', + ) + + extra_paths.append(scripts_dir) + + os.environ['PATH'] = os.pathsep.join(extra_paths + path) if not self._findprogram(pyexename): print("WARNING: Cannot find %s in search path" % pyexename)