Lines Matching +full:helper +full:- +full:module +full:- +full:imports
3 # Use of this source code is governed by a BSD-style license that can be
6 """Prints all non-system dependencies for the given module.
8 The primary use-case for this script is to generate the list of python modules
17 # Don't use any helper modules, or else they will end up in the results.
24 """Gets the paths of imported non-system python modules.
42 path = path[:-1]
60 args.extend(('--root', root))
62 args.extend(('--output', os.path.relpath(options.output, _SRC_ROOT)))
64 args.extend(('--gn-paths',))
66 args.extend(('--allowlist', os.path.relpath(allowlist, _SRC_ROOT)))
67 args.append(os.path.relpath(options.module, _SRC_ROOT))
75 """Returns an iterable of all non-test python files in the given directory."""
84 """Imports a module by its source file."""
86 # module.
89 # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
93 module = importlib.util.module_from_spec(spec)
94 sys.modules[module_name] = module
95 spec.loader.exec_module(module)
100 description='Prints all non-system dependencies for the given module.')
101 parser.add_argument('module',
102 help='The python module to analyze.')
103 parser.add_argument('--root', default='.',
105 parser.add_argument('--output',
107 parser.add_argument('--inplace', action='store_true',
109 'module, but with a .pydeps extension. Also sets the '
110 'root to the module\'s directory.')
111 parser.add_argument('--no-header', action='store_true',
113 parser.add_argument('--gn-paths', action='store_true',
115 parser.add_argument('--did-relaunch', action='store_true',
117 parser.add_argument('--allowlist',
121 help='Recursively include all non-test python files '
127 parser.error('Cannot use --inplace and --output at the same time!')
128 if not options.module.endswith('.py'):
129 parser.error('Input module path should end with .py suffix!')
130 options.output = options.module + 'deps'
131 options.root = os.path.dirname(options.module)
133 modules = [options.module]
134 if os.path.isdir(options.module):
135 modules = list(_FindPythonInDirectory(options.module, allow_test=True))
143 # Re-launch using vpython will cause us to pick up modules specified in
147 os.execvp('vpython3', ['vpython3'] + sys.argv + ['--did-relaunch'])
149 # Work-around for protobuf library not being loadable via importlib
156 for module in modules:
157 _ImportModuleByPath(module)