As for the 2nd question the only workaround I found is to use relative
imports, which I want to get rid of.
Let me give you an example. In my collection dir I have the plugins subdir
that has:

plugins
├── httpapi
│   └── sr.py
├── module_utils
│   └── sr.py
└── modules
    └── get.py

In my get.py I have to import a class from module_utils, and the full
import path looks like

from
ansible_collections.<namespace>.<collection>.plugins.module_utils.srlinux
import MyClass

How do I make my python instance to resolve this path? I understand that at
runtime ansible does add collections dir to the PYTHONPATH (or something of
sorts), but without running ansible, how do i make my dev environment to
resolve this path?

Thank you all for your help and valuable inputs.

PS. I can solve this with a relative path like

from ..module_utils.sr import MyClass

but I would like to not use relative imports if possible.


On Wed, Feb 22, 2023 at 9:48 PM Brian Coca <bc...@redhat.com> wrote:

> ls -l ~/.ansible/collections/ansible_collections/
> total 20
> lrwxrwxrwx 1 bcoca bcoca   54 Oct  7  2021 bcoca ->
> /home/bcoca/work/collections/ansible_collections/bcoca
>
> On Wed, Feb 22, 2023 at 3:45 PM Brian Coca <bc...@redhat.com> wrote:
> >
> > symlinks do work, but you still need an ansible_collections/ dir
> > before your collection
> >
> >
> >
> >
> > --
> > ----------
> > Brian Coca
>
>
>
> --
> ----------
> Brian Coca
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/CAFBEvLvgr7ZZZkvA9n2FrHwdFh-8HPw4zug9sjd1sG343EPvtw%40mail.gmail.com.

Reply via email to