Gordons installer or imputil problem?

Thomas Heller thomas.heller at ion-tof.com
Thu Aug 5 13:51:23 EDT 1999


Gordon,
I tried out your installer (the new beta) and am really impressed.
IMHO the best part is parsing the binary files (dlls, pyds) for dependecies.

I noticed a strange problem however, and I do not know where to look
for the solution.

Consider a simple python package:

directory 'package':
    file '__init__.py'
    file 'mod.py'

and the following scripts:

-----<script a>-----
print "Importing package"
import package
print "Importing package.mod"
import package.mod
print "Importing mod from package"
from package import mod
-----<EOF script a>-----

-----<script b>-----
print "Importing package"
import package
print "Importing mod from package"
from package import mod
print "Importing package.mod"
import package.mod
-----<EOF script b>-----

Since 'package' as well as 'package.mod' is imported
and modulefinder.py has no problems finding the needed files
and a.exe and b.exe are generated correctly.

Running the scripts shows the problem:

  C:\>a
  Importing package
  Importing package.mod1
  Importing mod1 from package

  C:\>b
  Importing package
  Importing mod1 from package
  Traceback (innermost last):
    File "C:\launch.py", line 5, in ?
      from package import mod1
  ImportError: cannot import name mod1

  C:\>

The only difference between a.py and b.py is that in the first case
 'import package.mod' is executed before 'from package import mod',
while in the other case the order is different.
Since I'm working with packages a lot, and normally use 'from package import
module'
I would stronly prefer to find a solution other than rewriting all the
import statements.


Thomas Heller
ION-TOF GmbH





More information about the Python-list mailing list