There is some directory with files and folders having some programming modules like Perl modules, python files and some other shell files. There is one main file in python(.py) to do some task which requires some of the modules not all. 

Consider a scenario where the main python files import some other python files and in the code its uses os.system('perl perl\_filename.pm') and this perl\_filename it self calls other perl modules and python files in between.

How do I find the all the files and modules used by this main python file at the end of execution.One solution is to read the code the from the start and finding dependencies by reading the code.But code base is so large that is not feasible.