Skip to content

Commit

Permalink
Adjust the awx-manage script to make use of importlib (ansible#15015)
Browse files Browse the repository at this point in the history
* Adjust the awx-manage script to make use of importlib

removing the deprecation warning.

* Synlink awx-manage in docker-compose

No longer need to rebuild docker-compose devel image to load change for `tools/docker-compose/awx-manage` in development environment

---------

Co-authored-by: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com>
  • Loading branch information
jbradberry and TheRealHaoLiu authored Apr 2, 2024
1 parent 7cdf1c7 commit 3edaaeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tools/ansible/roles/dockerfile/templates/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ ADD tools/scripts/awx-python /usr/bin/awx-python

{% if (build_dev|bool) or (kube_dev|bool) %}
RUN echo /awx_devel > /var/lib/awx/venv/awx/lib/python3.11/site-packages/awx.egg-link
ADD tools/docker-compose/awx-manage /usr/local/bin/awx-manage
RUN echo /awx_devel > /var/lib/awx/venv/awx/lib/python3.11/site-packages/awx.pth
RUN ln -sf /awx_devel/tools/docker-compose/awx-manage /usr/local/bin/awx-manage
RUN ln -sf /awx_devel/tools/scripts/awx-python /usr/bin/awx-python
RUN ln -sf /awx_devel/tools/scripts/rsyslog-4xx-recovery /usr/bin/rsyslog-4xx-recovery
{% endif %}
Expand Down
15 changes: 12 additions & 3 deletions tools/docker-compose/awx-manage
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#!/usr/bin/awx-python
# EASY-INSTALL-ENTRY-SCRIPT: 'awx','console_scripts','awx-manage'
import sys
from pkg_resources import load_entry_point
__requires__ = 'awx'
from importlib.metadata import distribution


def load_entry_point(dist, group, name):
dist_name, _, _ = dist.partition('==')
matches = (
entry_point
for entry_point in distribution(dist_name).entry_points
if entry_point.group == group and entry_point.name == name
)
return next(matches).load()


if __name__ == '__main__':
sys.exit(
Expand Down

0 comments on commit 3edaaeb

Please sign in to comment.