Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import fnmatch | 5 import fnmatch |
| 6 import imp | 6 import imp |
| 7 import logging | 7 import logging |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 deps_paths = bootstrap.ListAllDepsPaths(deps_file) | 30 deps_paths = bootstrap.ListAllDepsPaths(deps_file) |
| 31 return set(os.path.realpath(os.path.join( | 31 return set(os.path.realpath(os.path.join( |
| 32 path.GetChromiumSrcDir(), os.pardir, deps_path)) | 32 path.GetChromiumSrcDir(), os.pardir, deps_path)) |
| 33 for deps_path in deps_paths) | 33 for deps_path in deps_paths) |
| 34 | 34 |
| 35 | 35 |
| 36 def FindPythonDependencies(module_path): | 36 def FindPythonDependencies(module_path): |
| 37 logging.info('Finding Python dependencies of %s' % module_path) | 37 logging.info('Finding Python dependencies of %s' % module_path) |
| 38 | 38 |
| 39 # Load the module to inherit its sys.path modifications. | 39 # Load the module to inherit its sys.path modifications. |
| 40 sys.path.insert(0, os.path.abspath(os.path.dirname(module_path))) | |
|
nednguyen
2015/09/04 15:30:54
Can you unload the sys.path at the end of the func
| |
| 40 imp.load_source( | 41 imp.load_source( |
| 41 os.path.splitext(os.path.basename(module_path))[0], module_path) | 42 os.path.splitext(os.path.basename(module_path))[0], module_path) |
| 42 | 43 |
| 43 # Analyze the module for its imports. | 44 # Analyze the module for its imports. |
| 44 graph = modulegraph.ModuleGraph() | 45 graph = modulegraph.ModuleGraph() |
| 45 graph.run_script(module_path) | 46 graph.run_script(module_path) |
| 46 | 47 |
| 47 # Filter for only imports in Chromium. | 48 # Filter for only imports in Chromium. |
| 48 for node in graph.nodes(): | 49 for node in graph.nodes(): |
| 49 if not node.filename: | 50 if not node.filename: |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 | 227 |
| 227 def Run(self, args): | 228 def Run(self, args): |
| 228 target_paths = args.positional_args | 229 target_paths = args.positional_args |
| 229 dependencies = FindDependencies(target_paths, args) | 230 dependencies = FindDependencies(target_paths, args) |
| 230 if args.zip: | 231 if args.zip: |
| 231 ZipDependencies(target_paths, dependencies, args) | 232 ZipDependencies(target_paths, dependencies, args) |
| 232 print 'Zip archive written to %s.' % args.zip | 233 print 'Zip archive written to %s.' % args.zip |
| 233 else: | 234 else: |
| 234 print '\n'.join(sorted(dependencies)) | 235 print '\n'.join(sorted(dependencies)) |
| 235 return 0 | 236 return 0 |
| OLD | NEW |