mirror of
https://github.com/ansible/ansible.git
synced 2026-06-09 00:42:10 -04:00
parent
f1179b1f7d
commit
bae4284820
6 changed files with 51 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -94,6 +94,8 @@ Vagrantfile
|
|||
/lib/ansible_core.egg-info/
|
||||
# First used in the `devel` branch during Ansible 2.18 development.
|
||||
/ansible_core.egg-info/
|
||||
# First used in the `devel` branch during Ansible 2.21 development.
|
||||
lib/ansible_core-*.dist-info/
|
||||
# vendored lib dir
|
||||
lib/ansible/_vendor/*
|
||||
!lib/ansible/_vendor/__init__.py
|
||||
|
|
|
|||
2
changelogs/fragments/ansible-test-dist-info.yml
Normal file
2
changelogs/fragments/ansible-test-dist-info.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- ansible-test - Generate ``dist_info`` when running tests.
|
||||
3
test/integration/targets/ansible-test-metadata/aliases
Normal file
3
test/integration/targets/ansible-test-metadata/aliases
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
shippable/posix/group3 # runs in the distro test containers
|
||||
shippable/generic/group1 # runs in the default test container
|
||||
context/controller
|
||||
9
test/integration/targets/ansible-test-metadata/runme.sh
Executable file
9
test/integration/targets/ansible-test-metadata/runme.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
# Verify that importlib.metadata can find ansible-core using the PYTHONPATH set by ansible-test.
|
||||
# Regression test for https://github.com/ansible/ansible/issues/86695
|
||||
|
||||
set -eux
|
||||
|
||||
VERSION=$(python -c "from importlib.metadata import version; print(version('ansible-core'))")
|
||||
|
||||
test "$VERSION" = "$ANSIBLE_TEST_ANSIBLE_VERSION"
|
||||
|
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import typing as t
|
||||
|
||||
|
|
@ -12,6 +13,10 @@ from .constants import (
|
|||
SOFT_RLIMIT_NOFILE,
|
||||
)
|
||||
|
||||
from .io import (
|
||||
write_text_file,
|
||||
)
|
||||
|
||||
from .util import (
|
||||
common_environment,
|
||||
ApplicationError,
|
||||
|
|
@ -22,6 +27,7 @@ from .util import (
|
|||
ANSIBLE_SOURCE_ROOT,
|
||||
ANSIBLE_TEST_TOOLS_ROOT,
|
||||
MODE_FILE_EXECUTE,
|
||||
get_ansible_version,
|
||||
raw_command,
|
||||
verified_chmod,
|
||||
)
|
||||
|
|
@ -249,15 +255,12 @@ def get_cli_path(path: str) -> str:
|
|||
raise RuntimeError(path)
|
||||
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
@mutex
|
||||
def get_ansible_python_path(args: CommonConfig) -> str:
|
||||
"""
|
||||
Return a directory usable for PYTHONPATH, containing only the ansible package.
|
||||
If a temporary directory is required, it will be cached for the lifetime of the process and cleaned up at exit.
|
||||
"""
|
||||
del args # not currently used
|
||||
|
||||
try:
|
||||
return get_ansible_python_path.python_path # type: ignore[attr-defined]
|
||||
except AttributeError:
|
||||
|
|
@ -274,11 +277,38 @@ def get_ansible_python_path(args: CommonConfig) -> str:
|
|||
|
||||
os.symlink(ANSIBLE_LIB_ROOT, os.path.join(python_path, 'ansible'))
|
||||
|
||||
if not args.explain:
|
||||
generate_dist_info(python_path)
|
||||
|
||||
get_ansible_python_path.python_path = python_path # type: ignore[attr-defined]
|
||||
|
||||
return python_path
|
||||
|
||||
|
||||
def generate_dist_info(path: str) -> None:
|
||||
"""Generate a dist-info in the specified base directory."""
|
||||
version = get_ansible_version()
|
||||
metadata = f'''\
|
||||
Metadata-Version: 2.1
|
||||
Name: ansible-core
|
||||
Version: {version}
|
||||
'''
|
||||
python_path = pathlib.Path(path)
|
||||
|
||||
current_dist_info = python_path / f'ansible_core-{version}.dist-info'
|
||||
|
||||
for dist_info in pathlib.Path(path).glob('ansible_core-*.dist-info'):
|
||||
if dist_info == current_dist_info:
|
||||
continue
|
||||
shutil.rmtree(dist_info, ignore_errors=True)
|
||||
|
||||
metadata_path = current_dist_info / 'METADATA'
|
||||
if metadata_path.is_file():
|
||||
return
|
||||
|
||||
write_text_file(str(metadata_path), metadata, create_directories=True)
|
||||
|
||||
|
||||
class CollectionDetail:
|
||||
"""Collection detail."""
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ from ...io import (
|
|||
from ...util import (
|
||||
ApplicationError,
|
||||
display,
|
||||
get_ansible_version,
|
||||
SubprocessError,
|
||||
remove_tree,
|
||||
)
|
||||
|
|
@ -856,6 +857,7 @@ def integration_environment(
|
|||
ANSIBLE_CALLBACKS_ENABLED=','.join(sorted(set(callback_plugins))),
|
||||
ANSIBLE_TEST_CI=args.metadata.ci_provider or get_ci_provider().code,
|
||||
ANSIBLE_TEST_COVERAGE='check' if args.coverage_check else ('yes' if args.coverage else ''),
|
||||
ANSIBLE_TEST_ANSIBLE_VERSION=get_ansible_version(),
|
||||
OUTPUT_DIR=test_dir,
|
||||
INVENTORY_PATH=os.path.abspath(inventory_path),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue