We produce 2 Python applications that are distributed as egg files. We've produced them under Python 2.5.4 for years, but are now in the process of bringing them both up to 2.7.13. In this process, 1 of the 2 applications is now exhibiting weird behavior after install on 2.7.13.
When I easy_install.exe the egg, it appears to be successful in every way that I know how to look. However, when I try to import the module at the Python command line, I get an ImportError.
There are many strange things about this problem:
Here's the setup.py of the failing egg (with module name changed to foo to protect the innocent):
from setuptools import setup
setup(name='foo',
description='Foo Module',
packages=['foo'],
entry_points = {
'console_scripts': [
'foo = foo.foo:main',
],
},
)
And here is the setup.py of the working egg:
from setuptools import setup
setup(name='bar',
description='Bar Tool',
packages=['bar', 'bar.hexes', 'bar.barlib'],
entry_points = {
'console_scripts': [
'bar = bar.main:main',
],
},
)
Since I don't see any problems up until the moment I try to import the module, how can I debug this issue?
My leading suspect at the moment is the foo.foo reference in the console_scripts section of the setup.py. It sounds somewhat similar to the answer given by @joest in this problem.
The foo module could not be imported because there was no __init__.py
in the egg. For reasons I still don't fully understand, our x64 build machines produce that file automatically during creation of the egg (You will see a Creating missing __init__.py for foo
message), while the x86 build machines skip that step and produce a broken egg. Considering that we build Python itself and all the necessary modules as part of the process of building this egg, I don't see how the behavior could differ, but it does.
I just created a blank __init__.py
in the foo source directory, and now the eggs always build and import correctly.