From 7323d5dd0dadad1c706eae331526cd481785456a Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Mon, 30 Mar 2020 11:00:45 -0700 Subject: [PATCH] Fix references to old egg-info directory. --- .gitignore | 6 +++++- Makefile | 2 +- hacking/env-setup | 7 +++++-- lib/ansible/cli/scripts/ansible_cli_stub.py | 2 +- .../cli/scripts/ansible_connection_cli_stub.py | 2 +- test/integration/targets/egg-info/aliases | 1 + .../egg-info/lookup_plugins/import_pkg_resources.py | 11 +++++++++++ test/integration/targets/egg-info/tasks/main.yml | 3 +++ test/lib/ansible_test/_internal/executor.py | 4 ++-- .../_internal/provider/source/unversioned.py | 1 + 10 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 test/integration/targets/egg-info/aliases create mode 100644 test/integration/targets/egg-info/lookup_plugins/import_pkg_resources.py create mode 100644 test/integration/targets/egg-info/tasks/main.yml diff --git a/.gitignore b/.gitignore index c9a324dda97..4c437ee809d 100644 --- a/.gitignore +++ b/.gitignore @@ -71,7 +71,11 @@ coverage.xml venv Vagrantfile .vagrant -ansible.egg-info/ +# Backwards compatibility with `stable-2.9` and earlier branches. +# Also used in the `devel` branch during early Ansible 2.10 development. +/lib/ansible.egg-info/ +# First used in the `devel` branch during Ansible 2.10 development. +/lib/ansible_base.egg-info/ /shippable/ /test/integration/cloud-config-*.* !/test/integration/cloud-config-*.*.template diff --git a/Makefile b/Makefile index d7daec8a05e..bd8e03acd30 100644 --- a/Makefile +++ b/Makefile @@ -169,7 +169,7 @@ clean: @echo "Cleaning up distutils stuff" rm -rf build rm -rf dist - rm -rf lib/ansible.egg-info/ + rm -rf lib/ansible*.egg-info/ @echo "Cleaning up byte compiled python stuff" find . -type f -regex ".*\.py[co]$$" -delete find . -type d -name "__pycache__" -delete diff --git a/hacking/env-setup b/hacking/env-setup index d4ac8300073..46f58fecda5 100644 --- a/hacking/env-setup +++ b/hacking/env-setup @@ -61,8 +61,11 @@ expr "$MANPATH" : "${PREFIX_MANPATH}.*" > /dev/null || prepend_path MANPATH "$PR # Do the work in a function so we don't repeat ourselves later gen_egg_info() { - if [ -e "$PREFIX_PYTHONPATH/ansible.egg-info" ] ; then - \rm -rf "$PREFIX_PYTHONPATH/ansible.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 } diff --git a/lib/ansible/cli/scripts/ansible_cli_stub.py b/lib/ansible/cli/scripts/ansible_cli_stub.py index 231c11cd5eb..2ede010e89c 100755 --- a/lib/ansible/cli/scripts/ansible_cli_stub.py +++ b/lib/ansible/cli/scripts/ansible_cli_stub.py @@ -22,7 +22,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -__requires__ = ['ansible'] +__requires__ = ['ansible_base'] import errno diff --git a/lib/ansible/cli/scripts/ansible_connection_cli_stub.py b/lib/ansible/cli/scripts/ansible_connection_cli_stub.py index 204b67f2ebc..f58ac15d125 100755 --- a/lib/ansible/cli/scripts/ansible_connection_cli_stub.py +++ b/lib/ansible/cli/scripts/ansible_connection_cli_stub.py @@ -4,7 +4,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -__requires__ = ['ansible'] +__requires__ = ['ansible_base'] import fcntl diff --git a/test/integration/targets/egg-info/aliases b/test/integration/targets/egg-info/aliases new file mode 100644 index 00000000000..a6dafcf8cd8 --- /dev/null +++ b/test/integration/targets/egg-info/aliases @@ -0,0 +1 @@ +shippable/posix/group1 diff --git a/test/integration/targets/egg-info/lookup_plugins/import_pkg_resources.py b/test/integration/targets/egg-info/lookup_plugins/import_pkg_resources.py new file mode 100644 index 00000000000..c0c5ccd503b --- /dev/null +++ b/test/integration/targets/egg-info/lookup_plugins/import_pkg_resources.py @@ -0,0 +1,11 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import pkg_resources + +from ansible.plugins.lookup import LookupBase + + +class LookupModule(LookupBase): + def run(self, terms, variables, **kwargs): + return ['ok'] diff --git a/test/integration/targets/egg-info/tasks/main.yml b/test/integration/targets/egg-info/tasks/main.yml new file mode 100644 index 00000000000..d7b886c00cc --- /dev/null +++ b/test/integration/targets/egg-info/tasks/main.yml @@ -0,0 +1,3 @@ +- name: Make sure pkg_resources can be imported by plugins + debug: + msg: "{{ lookup('import_pkg_resources') }}" diff --git a/test/lib/ansible_test/_internal/executor.py b/test/lib/ansible_test/_internal/executor.py index 787b9667957..9e7e835a513 100644 --- a/test/lib/ansible_test/_internal/executor.py +++ b/test/lib/ansible_test/_internal/executor.py @@ -355,12 +355,12 @@ def generate_egg_info(args): # inclusion of the version number in the path is optional # see: https://setuptools.readthedocs.io/en/latest/formats.html#filename-embedded-metadata - egg_info_path = ANSIBLE_LIB_ROOT + '-%s.egg-info' % ansible_version + egg_info_path = ANSIBLE_LIB_ROOT + '_base-%s.egg-info' % ansible_version if os.path.exists(egg_info_path): return - egg_info_path = ANSIBLE_LIB_ROOT + '.egg-info' + egg_info_path = ANSIBLE_LIB_ROOT + '_base.egg-info' if os.path.exists(egg_info_path): return diff --git a/test/lib/ansible_test/_internal/provider/source/unversioned.py b/test/lib/ansible_test/_internal/provider/source/unversioned.py index 60197280835..09105789caa 100644 --- a/test/lib/ansible_test/_internal/provider/source/unversioned.py +++ b/test/lib/ansible_test/_internal/provider/source/unversioned.py @@ -37,6 +37,7 @@ class UnversionedSource(SourceProvider): '.pytest_cache', '__pycache__', 'ansible.egg-info', + 'ansible_base.egg-info', ) kill_sub_dir = {