[SciPy-dev] scipy import issue
David C. Morrill
dmorrill at scipy.org
Mon Apr 1 15:56:24 CST 2002
Recently I've been working on a Python app that uses scipy (among several
other packages). I'm now in a position where I want to create a nice Windows
installer that will allow users of the program to install/run the program
without even knowing that the program is written in Python (i.e. they will
not need to install Python or any requisite packages themselves).
To that end, I have been using Gordon McMillan's Python Installer tool to
automatically analyze/build the collection of files I will need to ship to
users. However, I have been having a problem with the scipy parts of the app
because of the way that scipy's __init__.py files currently are written.
Installer basically performs a static dependency analysis of both the Python
code and the shared library files to determine the set of files that
comprise the program. For Python source files, this means looking for
'import' statements. Unfortunately, scipy dynamically imports all of its
internal modules using functions, which causes Installer to incorrectly
analyze most of scipy.
I've gone through all of the scipy __init__.py modules and modified them so
that they statically import all of the modules. I've preserved the functions
calls that previously imported the modules, but now they are only used to
build up the value of the __all__ variable (i.e. I've removed the lines that
dynamically import modules).
This change allows tools like Installer to correctly analyze programs that
use scipy, and still seems to give the same result for 'from scipy import *'
when executed from within a Python interpreter shell.
I'd like to commit these changes to CVS, but being a scipy newbie, I want to
to see if anyone has any comments before I go ahead with this change.
More information about the Scipy-dev