mirror of
https://github.com/ansible/ansible.git
synced 2025-11-30 23:16:08 +07:00
ansible-test - Remove generation of egg-info (#83786)
Also remove egg-info generation from hacking/env-setup scripts.
This commit is contained in:
2
changelogs/fragments/ansible-test-no-egg-info.yml
Normal file
2
changelogs/fragments/ansible-test-no-egg-info.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- ansible-test - An ``ansible_core.egg-info`` directory is no longer generated when running tests.
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user