Commit 020036f8 authored by David Wilson's avatar David Wilson

core: add a nasty hack for Ansible modules.

parent 875ee29d
......@@ -546,7 +546,13 @@ class Importer(object):
self._present[fullname] = pkg_present
else:
mod.__package__ = fullname.rpartition('.')[0] or None
code = compile(self.get_source(fullname), mod.__file__, 'exec')
# TODO: monster hack: work around modules now being imported as their
# actual name, so when Ansible "apt.py" tries to "import apt", it gets
# itself. Instead force absolute imports during compilation.
flags = 0x4000 if fullname.startswith('ansible') else 0
source = self.get_source(fullname)
code = compile(source, mod.__file__, 'exec', flags, True)
exec code in vars(mod)
return mod
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment