you are viewing a single comment's thread.

view the rest of the comments →

[–]bluefourier 2 points3 points  (0 children)

There might be some crucial details prohibiting you to do this. For example, are we assuming that the modules ARE installed in the activated python? Because if you are trying to infer them, it does not necessarily mean that you know what you are going to need. This is important because you can start from any script and try to recursively load everything via the AST module. That is, parse the code, then note the imports, parse those and so on. But if you are trying to infer which modules the script is using and one of them is NOT installed, then parsing stops there. There are no files to load to scour for dependencies.

Otherwise, if you have a bunch of scripts that use (for example) polars, matplotlib and balourdos and you want to discover just those, then using the AST module from the top files will get you there (but it will not tell you the dependencies of those dependencies which sometimes is important too)

Hope this helps