At 12:34 PM 7/26/2007 -0400, Stanley A. Klein wrote: >I disabled the __init__.py's on the namespace packages by renaming them. A >sys.modules.keys() shows the namespace packages in the list. Then I >interactively did the first three statements of the test_traits.py >program: > >import unittest >from enthought.traits.api import * >import enthought.traits.standard as standard > >The last statement failed with an error: > >Traceback (most recent call last): > File "test_traits.py", line 23, in ? > import enthought.traits.standard as standard >AttributeError: 'module' object has no attribute 'traits' > >If I then interactively do "import enthought.traits.standard", it works >without error.
Aha. Try this. In each nspkg.pth file, add "import x" lines, where "x" is any namespace package referenced in that file. That is, if the file refers to enthought.traits, add a line saying "import enthought.traits" at the *end* of the file. Do this in every file, for every module mentioned in that file. Get rid of the __init__.py's and give it a whirl. I think that what's happening is that the .pth files I'm generating are not settting sys.modules['enthought'].traits = sys.modules['enthought.traits']; adding the import statements should fix that. If it works, I'll change setuptools to generate the files with the added import statements. Thanks for taking the time to help track this down. It looks like I only tested this with top--level namespace packages (e.g. peak.*, zope.*) and not sub-packages (like enthought.traits). _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig