Learning which modules were loaded

J

James Stroud

I am rolling up a distribution of a program I wrote. It uses matplotlib
with tkagg so the bundle is HUGE (47 MB, 14 MB after bz compression). Is
there any way to run the program, put it through all of its paces, and
then inspect which modules were loaded. I would like to gather these in
a list and delete any others that py2app and py2exe attempt to include.
Currently, these (or py2app, at least) use dependency graphing and
icnlude everything belonging to pylab, matplotlib, and numpy by default.
I don't want everything, I only want what my program needs to run. For
example, some modules are imported by functions (in Pmw, for example)
that never get called. I don't want to include these.

Thanks in advance for any help.

James
 
G

Gary Herron

James said:
I am rolling up a distribution of a program I wrote. It uses
matplotlib with tkagg so the bundle is HUGE (47 MB, 14 MB after bz
compression). Is there any way to run the program, put it through all
of its paces, and then inspect which modules were loaded. I would like
to gather these in a list and delete any others that py2app and py2exe
attempt to include. Currently, these (or py2app, at least) use
dependency graphing and icnlude everything belonging to pylab,
matplotlib, and numpy by default. I don't want everything, I only want
what my program needs to run. For example, some modules are imported
by functions (in Pmw, for example) that never get called. I don't want
to include these.

Thanks in advance for any help.

James

Import sys, then look at sys.modules. It's a dictionary that contains
all the imported modules, but I suspect you'll find that it's much
easier to let py2app and py2exe determine what's imported than it is to
go through sys.modules yourself.

Gary Herron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top