Skip to content

Commit

Permalink
Use correct init_plugin_loader
Browse files Browse the repository at this point in the history
Fixes: #443
  • Loading branch information
ssbarnea committed Jan 7, 2025
1 parent 5d657e5 commit 0352b7d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/ansible_compat/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,20 +343,16 @@ def _ensure_module_available(self) -> None:
if not Runtime.initialized:
col_path = [f"{self.cache_dir}/collections"]
# noinspection PyProtectedMember
# pylint: disable=import-outside-toplevel,no-name-in-module
from ansible.plugins.loader import init_plugin_loader
from ansible.utils.collection_loader._collection_finder import ( # pylint: disable=import-outside-toplevel
_AnsibleCollectionFinder, # noqa: PLC2701
)

# noinspection PyProtectedMember
# pylint: disable=protected-access
col_path += self.config.collections_paths
col_path += os.path.dirname( # noqa: PTH120
os.environ.get(ansible_collections_path(), "."),
).split(":")
_AnsibleCollectionFinder( # noqa: SLF001
paths=col_path,
)._install() # pylint: disable=protected-access
Runtime.initialized = True
)._remove() # pylint: disable=protected-access
init_plugin_loader(col_path)

def clean(self) -> None:
"""Remove content of cache_dir."""
Expand Down

0 comments on commit 0352b7d

Please sign in to comment.