[Python-Dev] ModuleFinder patch

Thomas Heller thomas.heller@ion-tof.com
Wed, 19 Sep 2001 19:51:53 +0200


I've uploaded a freeze/ModuleFinder patch to sf, #462936.

This patch adds two improvements:

1. ModuleFinder now keeps track of which module is 
imported by whom.

2. ModuleFinder, when instantiated with the new 
scan_extdeps=1 argument, tries to track dependencies 
of builtin and extension modules.

I'd love to hear some comments especially on the last point,
so I'll shortly explain how it works.

ModuleFinder starts a separate python interpreter process
with a command line of '-S -v -c "import <builtin_or_extension>"',
pipes this through popen(), and scans the error-output for
lines of the form 'import blabla # ....'.
This is somewhat expensive, but it is the only way I've found
so far to find out about these dependencies.
Examples are:
The multiarray extension needs the _numpy extension.
Every extension using ExtensionClass needs this.
cPickle needs copy_reg and other modules.

Any other ideas?

Regards,

Thomas