Skip to content

Commit

Permalink
[find_dependencies.py] Explicitly exclude all files under python sys.…
Browse files Browse the repository at this point in the history
…prefix.

When running the dependency finder under a VirtualEnv (such as vpython),
it will accidentally pick up dependencies from the sys.prefix.

Bug: 804174,818054
Change-Id: Ic6a677413ffed782ab49a772cc0eb73b7e8a87b2
Reviewed-on: https://chromium-review.googlesource.com/944899
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: David Tu <dtu@chromium.org>
Reviewed-by: Ned Nguyen <nednguyen@google.com>
Cr-Commit-Position: refs/heads/master@{#540459}
  • Loading branch information
riannucci authored and Commit Bot committed Mar 2, 2018
1 parent 7d001de commit bbbfd60
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/perf/core/find_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def FindPythonDependencies(module_path):
if modulegraph is None:
raise import_error

prefixes = [sys.prefix]
if hasattr(sys, 'real_prefix'):
prefixes.append(sys.real_prefix)
logging.info('Excluding Prefixes: %r', prefixes)

sys_path = sys.path
sys.path = list(sys_path)
try:
Expand Down Expand Up @@ -75,6 +80,10 @@ def FindPythonDependencies(module_path):
if not path.IsSubpath(module_path, path_util.GetChromiumSrcDir()):
continue

# Exclude any dependencies which exist in the python installation.
if any(path.IsSubpath(module_path, pfx) for pfx in prefixes):
continue

yield module_path
if node.packagepath is not None:
for p in node.packagepath:
Expand Down

0 comments on commit bbbfd60

Please sign in to comment.