Improve ansible-test python interpreter selection. (#54445)

This commit is contained in:
Matt Clay 2019-03-27 16:40:27 -07:00 committed by GitHub
parent 3637ce4538
commit 785afc7a53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 203 additions and 99 deletions

View file

@ -17,12 +17,14 @@ from lib.util import (
display,
raw_command,
get_docker_completion,
get_remote_completion,
generate_pip_command,
read_lines_without_comments,
MAXFD,
)
from lib.delegation import (
check_delegation_args,
delegate,
)
@ -96,6 +98,7 @@ def main():
display.color = config.color
display.info_stderr = (isinstance(config, SanityConfig) and config.lint) or (isinstance(config, IntegrationConfig) and config.list_targets)
check_startup()
check_delegation_args(config)
configure_timeout(config)
display.info('RLIMIT_NOFILE: %s' % (CURRENT_RLIMIT_NOFILE,), verbosity=2)
@ -423,6 +426,11 @@ def parse_args():
parents=[common],
help='open an interactive shell')
shell.add_argument('--python',
metavar='VERSION',
choices=SUPPORTED_PYTHON_VERSIONS + ('default',),
help='python version: %s' % ', '.join(SUPPORTED_PYTHON_VERSIONS))
shell.set_defaults(func=command_shell,
config=ShellConfig)
@ -584,6 +592,11 @@ def add_environments(parser, tox_version=False, tox_only=False):
action='store_true',
help='install command requirements')
parser.add_argument('--python-interpreter',
metavar='PATH',
default=None,
help='path to the docker or remote python interpreter')
environments = parser.add_mutually_exclusive_group()
environments.add_argument('--local',
@ -617,6 +630,7 @@ def add_environments(parser, tox_version=False, tox_only=False):
remote_provider=None,
remote_aws_region=None,
remote_terminate=None,
python_interpreter=None,
)
return
@ -752,7 +766,7 @@ def complete_remote(prefix, parsed_args, **_):
"""
del parsed_args
images = read_lines_without_comments('test/runner/completion/remote.txt', remove_blank_lines=True)
images = sorted(get_remote_completion().keys())
return [i for i in images if i.startswith(prefix)]
@ -765,7 +779,7 @@ def complete_remote_shell(prefix, parsed_args, **_):
"""
del parsed_args
images = read_lines_without_comments('test/runner/completion/remote.txt', remove_blank_lines=True)
images = sorted(get_remote_completion().keys())
# 2008 doesn't support SSH so we do not add to the list of valid images
images.extend(["windows/%s" % i for i in read_lines_without_comments('test/runner/completion/windows.txt', remove_blank_lines=True) if i != '2008'])