diff --git a/changelogs/fragments/ansible-test-no-egg-info.yml b/changelogs/fragments/ansible-test-no-egg-info.yml new file mode 100644 index 00000000000..4b36efa13b8 --- /dev/null +++ b/changelogs/fragments/ansible-test-no-egg-info.yml @@ -0,0 +1,2 @@ +minor_changes: + - ansible-test - An ``ansible_core.egg-info`` directory is no longer generated when running tests. diff --git a/hacking/env-setup b/hacking/env-setup index 0a86e0fe4fb..df1ea4020f2 100644 --- a/hacking/env-setup +++ b/hacking/env-setup @@ -57,22 +57,6 @@ expr "$PYTHONPATH" : "${ANSIBLE_TEST_PREFIX_PYTHONPATH}.*" > /dev/null || prepen expr "$PATH" : "${PREFIX_PATH}.*" > /dev/null || prepend_path PATH "$PREFIX_PATH" expr "$MANPATH" : "${PREFIX_MANPATH}.*" > /dev/null || prepend_path MANPATH "$PREFIX_MANPATH" -# -# Generate egg_info so that pkg_resources works -# - -# Do the work in a function so we don't repeat ourselves later -gen_egg_info() -{ - # check for current and past egg-info directory names - if ls "$PREFIX_PYTHONPATH"/ansible*.egg-info >/dev/null 2>&1; then - # bypass shell aliases with leading backslash - # see https://github.com/ansible/ansible/pull/11967 - \rm -rf "$PREFIX_PYTHONPATH"/ansible*.egg-info - fi - "$PYTHON_BIN" setup.py egg_info -} - if [ "$ANSIBLE_DEV_HOME" != "$PWD" ] ; then current_dir="$PWD" else @@ -81,10 +65,8 @@ fi ( cd "$ANSIBLE_DEV_HOME" if [ "$verbosity" = silent ] ; then - gen_egg_info > /dev/null 2>&1 & find . -type f -name "*.pyc" -exec rm -f {} \; > /dev/null 2>&1 else - gen_egg_info find . -type f -name "*.pyc" -exec rm -f {} \; fi cd "$current_dir" diff --git a/hacking/env-setup.fish b/hacking/env-setup.fish index 529b57333ef..ee945ec1452 100644 --- a/hacking/env-setup.fish +++ b/hacking/env-setup.fish @@ -64,25 +64,11 @@ if not set -q PYTHON_BIN end end -# Generate egg_info so that pkg_resources works -function gen_egg_info - # Check if ansible*.egg-info directory exists and remove if found - if test -d $PREFIX_PYTHONPATH/ansible*.egg-info - rm -rf $PREFIX_PYTHONPATH/ansible*.egg-info - end - # Execute setup.py egg_info using the chosen Python interpreter - eval $PYTHON_BIN setup.py egg_info -end - pushd $ANSIBLE_HOME if test -n "$QUIET" - # Run gen_egg_info in the background and redirect output to /dev/null - gen_egg_info &> /dev/null # Remove any .pyc files found find . -type f -name "*.pyc" -exec rm -f '{}' ';' &> /dev/null else - # Run gen_egg_info - gen_egg_info # Remove any .pyc files found find . -type f -name "*.pyc" -exec rm -f '{}' ';' # Display setup details diff --git a/test/lib/ansible_test/_internal/ansible_util.py b/test/lib/ansible_test/_internal/ansible_util.py index c2d363506b3..909e3c3de6e 100644 --- a/test/lib/ansible_test/_internal/ansible_util.py +++ b/test/lib/ansible_test/_internal/ansible_util.py @@ -11,10 +11,6 @@ from .constants import ( SOFT_RLIMIT_NOFILE, ) -from .io import ( - write_text_file, -) - from .util import ( common_environment, ApplicationError, @@ -25,7 +21,6 @@ from .util import ( ANSIBLE_SOURCE_ROOT, ANSIBLE_TEST_TOOLS_ROOT, MODE_FILE_EXECUTE, - get_ansible_version, raw_command, verified_chmod, ) @@ -251,12 +246,15 @@ 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: @@ -273,38 +271,11 @@ def get_ansible_python_path(args: CommonConfig) -> str: os.symlink(ANSIBLE_LIB_ROOT, os.path.join(python_path, 'ansible')) - if not args.explain: - generate_egg_info(python_path) - get_ansible_python_path.python_path = python_path # type: ignore[attr-defined] return python_path -def generate_egg_info(path: str) -> None: - """Generate an egg-info in the specified base directory.""" - # minimal PKG-INFO stub following the format defined in PEP 241 - # required for older setuptools versions to avoid a traceback when importing pkg_resources from packages like cryptography - # newer setuptools versions are happy with an empty directory - # including a stub here means we don't need to locate the existing file or run any tools to generate it when running from source - pkg_info = ''' -Metadata-Version: 1.0 -Name: ansible -Version: %s -Platform: UNKNOWN -Summary: Radically simple IT automation -Author-email: info@ansible.com -License: GPLv3+ -''' % get_ansible_version() - - pkg_info_path = os.path.join(path, 'ansible_core.egg-info', 'PKG-INFO') - - if os.path.exists(pkg_info_path): - return - - write_text_file(pkg_info_path, pkg_info.lstrip(), create_directories=True) - - class CollectionDetail: """Collection detail."""