Created
May 9, 2018 01:16
-
-
Save SkamDart/3fd5172c1bf9e01042e4a79f1a555177 to your computer and use it in GitHub Desktop.
Determines which modules are used by a python script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from modulefinder import ModuleFinder | |
import sys | |
def print_dependencies(filename): | |
f = ModuleFinder() | |
f.run_script(filename) | |
names = list(f.modules.keys()) | |
basemods = sorted(set([name.split(".")[0] for name in names])) | |
print("\n".join(basemods)) | |
if __name__ == '__main__': | |
print_dependencies(sys.argv[1]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment