[Build] print_python_deps.py: Use importlib.util for Python 3.
This CL removes the warning message DeprecationWarning: the imp module is deprecated... from running print_python_deps.py on SuperSize (or other Python 3 projects). The key is to follow the recommendation to use importlib. Caveats: * The library only in Python 3, so we need to keep on using imp for Python 2. * This requires Python version detection and using import statements locally. * importlib.util is more fine-grained than expected, and requires: * Manually extracting module name from module path. * Explicitly adding loaded module to sys.modules. Meanwhile, once the module runs, the modules it transitively uses will be automatically added. Fixed: 1069660 Change-Id: I41b6be8975db1219da006e0c9e5d98b42acf15c8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145094Reviewed-by:Andrew Grieve <agrieve@chromium.org> Commit-Queue: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#758136}
Showing
Please register or sign in to comment