Importing Between Modules

Hello,

I am creating a module for yaourt, a front end for the pacman package manager wrapper [1]. Since yaourt proxies all the syntax of pacman, I refactored the pacman module to expose all operations in a class, PacmanModule [2], which parameterizes the command name allowing pacman and the variety frontends to share the same code. However, the importing the PacmanModule class from yaourt.py fails with an “No module named ansible.modules.packaging.os.pacman” exists. Do I have namespace incorrect? Is there something about the way modules are loaded/executed that prevents cross module imports?

Thanks for your help,
-John

[1]: https://archlinux.fr/yaourt-en
[2]: https://gist.github.com/jburwell/064ba48d3c180641fc6b7f6d9c2dd381

Modules get copied to the target machine, they won't include other
modules, so this will fail. Well, except maybe on localhost or require
all machines to have Ansible installed.

What you can do is refactor both modules to put shared code under
module_utils, which does get copied when a module imports it.