From 9ab63986ad528a6ad5bf4c59fe104d5106d6ef9b Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 19 Sep 2024 09:56:46 -0500 Subject: [PATCH] ansible-test no longer needs special casing in `__main__.py` (#83962) --- lib/ansible/__main__.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/lib/ansible/__main__.py b/lib/ansible/__main__.py index cb7006285b4..afdd2849739 100644 --- a/lib/ansible/__main__.py +++ b/lib/ansible/__main__.py @@ -3,9 +3,6 @@ from __future__ import annotations import argparse -import importlib -import os -import sys from importlib.metadata import distribution @@ -19,22 +16,10 @@ def main(): ep_map = {_short_name(ep.name): ep for ep in dist.entry_points if ep.group == 'console_scripts'} parser = argparse.ArgumentParser(prog='python -m ansible', add_help=False) - parser.add_argument('entry_point', choices=list(ep_map) + ['test']) + parser.add_argument('entry_point', choices=list(ep_map)) args, extra = parser.parse_known_args() - if args.entry_point == 'test': - ansible_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - source_root = os.path.join(ansible_root, 'test', 'lib') - - if os.path.exists(os.path.join(source_root, 'ansible_test', '_internal', '__init__.py')): - # running from source, use that version of ansible-test instead of any version that may already be installed - sys.path.insert(0, source_root) - - module = importlib.import_module('ansible_test._util.target.cli.ansible_test_cli_stub') - main = module.main - else: - main = ep_map[args.entry_point].load() - + main = ep_map[args.entry_point].load() main([args.entry_point] + extra)