Need clue with import hackery
Gordon McMillan
gmcm at hypernet.com
Fri Aug 3 10:33:08 EDT 2001
[posted and mailed]
Richard Jones wrote:
> In the roundup project, I (possibly foolishly) decided to make the
> roundup instances python packages.
I'd quibble with that "possibly" :-).
[snip]
> The roundup library code, when asked to do something, is passed the
> instance_home "/home/roundup/issue_tracker". It does:
>
> path, instance = os.path.split(instance_home)
> sys.path.insert(0, path)
> try:
> instance = __import__(instance)
> finally:
> del sys.path[0]
Which means that roundup will not work with freeze, mac's
BuildApplication, Installer or py2exe.
If these roundup extensions (is that a fair characterization?)
were installed as subpackages of roundup, then they might be
workable.
Your later post (using imp.load_module or imp.load_package) is
pure poison for these tools.
Don't know anything about imp.load_package, but imp.load_module
is sort of equivalent to:
if sys.modules.has_key('mymodule'):
reload(mymodule)
else:
import mymodule
so I'd be careful of side effects in normal Python, too.
- Gordon
More information about the Python-list
mailing list