mirror of
https://github.com/ansible/ansible
synced 2026-06-19 07:35:52 +00:00
committed by
GitHub
parent
f1179b1f7d
commit
bae4284820
@@ -94,6 +94,8 @@ Vagrantfile
|
|||||||
/lib/ansible_core.egg-info/
|
/lib/ansible_core.egg-info/
|
||||||
# First used in the `devel` branch during Ansible 2.18 development.
|
# First used in the `devel` branch during Ansible 2.18 development.
|
||||||
/ansible_core.egg-info/
|
/ansible_core.egg-info/
|
||||||
|
# First used in the `devel` branch during Ansible 2.21 development.
|
||||||
|
lib/ansible_core-*.dist-info/
|
||||||
# vendored lib dir
|
# vendored lib dir
|
||||||
lib/ansible/_vendor/*
|
lib/ansible/_vendor/*
|
||||||
!lib/ansible/_vendor/__init__.py
|
!lib/ansible/_vendor/__init__.py
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
minor_changes:
|
||||||
|
- ansible-test - Generate ``dist_info`` when running tests.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
shippable/posix/group3 # runs in the distro test containers
|
||||||
|
shippable/generic/group1 # runs in the default test container
|
||||||
|
context/controller
|
||||||
@@ -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 json
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
@@ -12,6 +13,10 @@ from .constants import (
|
|||||||
SOFT_RLIMIT_NOFILE,
|
SOFT_RLIMIT_NOFILE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from .io import (
|
||||||
|
write_text_file,
|
||||||
|
)
|
||||||
|
|
||||||
from .util import (
|
from .util import (
|
||||||
common_environment,
|
common_environment,
|
||||||
ApplicationError,
|
ApplicationError,
|
||||||
@@ -22,6 +27,7 @@ from .util import (
|
|||||||
ANSIBLE_SOURCE_ROOT,
|
ANSIBLE_SOURCE_ROOT,
|
||||||
ANSIBLE_TEST_TOOLS_ROOT,
|
ANSIBLE_TEST_TOOLS_ROOT,
|
||||||
MODE_FILE_EXECUTE,
|
MODE_FILE_EXECUTE,
|
||||||
|
get_ansible_version,
|
||||||
raw_command,
|
raw_command,
|
||||||
verified_chmod,
|
verified_chmod,
|
||||||
)
|
)
|
||||||
@@ -249,15 +255,12 @@ def get_cli_path(path: str) -> str:
|
|||||||
raise RuntimeError(path)
|
raise RuntimeError(path)
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
|
||||||
@mutex
|
@mutex
|
||||||
def get_ansible_python_path(args: CommonConfig) -> str:
|
def get_ansible_python_path(args: CommonConfig) -> str:
|
||||||
"""
|
"""
|
||||||
Return a directory usable for PYTHONPATH, containing only the ansible package.
|
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.
|
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:
|
try:
|
||||||
return get_ansible_python_path.python_path # type: ignore[attr-defined]
|
return get_ansible_python_path.python_path # type: ignore[attr-defined]
|
||||||
except AttributeError:
|
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'))
|
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]
|
get_ansible_python_path.python_path = python_path # type: ignore[attr-defined]
|
||||||
|
|
||||||
return python_path
|
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:
|
class CollectionDetail:
|
||||||
"""Collection detail."""
|
"""Collection detail."""
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ from ...io import (
|
|||||||
from ...util import (
|
from ...util import (
|
||||||
ApplicationError,
|
ApplicationError,
|
||||||
display,
|
display,
|
||||||
|
get_ansible_version,
|
||||||
SubprocessError,
|
SubprocessError,
|
||||||
remove_tree,
|
remove_tree,
|
||||||
)
|
)
|
||||||
@@ -856,6 +857,7 @@ def integration_environment(
|
|||||||
ANSIBLE_CALLBACKS_ENABLED=','.join(sorted(set(callback_plugins))),
|
ANSIBLE_CALLBACKS_ENABLED=','.join(sorted(set(callback_plugins))),
|
||||||
ANSIBLE_TEST_CI=args.metadata.ci_provider or get_ci_provider().code,
|
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_COVERAGE='check' if args.coverage_check else ('yes' if args.coverage else ''),
|
||||||
|
ANSIBLE_TEST_ANSIBLE_VERSION=get_ansible_version(),
|
||||||
OUTPUT_DIR=test_dir,
|
OUTPUT_DIR=test_dir,
|
||||||
INVENTORY_PATH=os.path.abspath(inventory_path),
|
INVENTORY_PATH=os.path.abspath(inventory_path),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user