Description: use py3 Use python 3 for all helper scripts during build . This allows us to not depend on python 2 anymore for building. Author: Lee Garrett Forwarded: not-needed Last-Update: 2021-11-06 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/docs/bin/find-plugin-refs.py +++ b/docs/bin/find-plugin-refs.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # To run this script, first make webdocs in the toplevel of the checkout. This will generate all # rst files from their sources. Then run this script ./docs/bin/find-plugin-refs.py --- a/lib/ansible/cli/scripts/ansible_connection_cli_stub.py +++ b/lib/ansible/cli/scripts/ansible_connection_cli_stub.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) --- a/packaging/sdist/check-link-behavior.py +++ b/packaging/sdist/check-link-behavior.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Checks for link behavior required for sdist to retain symlinks.""" from __future__ import (absolute_import, division, print_function) --- a/test/integration/targets/cli/test-cli.py +++ b/test/integration/targets/cli/test-cli.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2019 Matt Martz # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- a/test/integration/targets/gathering/uuid.fact +++ b/test/integration/targets/gathering/uuid.fact @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- --- a/test/integration/targets/gathering_facts/uuid.fact +++ b/test/integration/targets/gathering_facts/uuid.fact @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- --- a/test/integration/targets/group/files/gidget.py +++ b/test/integration/targets/group/files/gidget.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import (absolute_import, division, print_function) __metaclass__ = type --- a/test/integration/targets/module_utils/module_utils/foo.py +++ b/test/integration/targets/module_utils/module_utils/foo.py @@ -1,3 +1,3 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 foo = "FOO FROM foo.py" --- a/test/integration/targets/module_utils/module_utils/sub/bam.py +++ b/test/integration/targets/module_utils/module_utils/sub/bam.py @@ -1,3 +1,3 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 bam = "BAM FROM sub/bam.py" --- a/test/integration/targets/module_utils/module_utils/sub/bam/bam.py +++ b/test/integration/targets/module_utils/module_utils/sub/bam/bam.py @@ -1,3 +1,3 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 bam = "BAM FROM sub/bam/bam.py" --- a/test/integration/targets/module_utils/module_utils/sub/bar/bam.py +++ b/test/integration/targets/module_utils/module_utils/sub/bar/bam.py @@ -1,3 +1,3 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 bam = "BAM FROM sub/bar/bam.py" --- a/test/integration/targets/module_utils/module_utils/sub/bar/bar.py +++ b/test/integration/targets/module_utils/module_utils/sub/bar/bar.py @@ -1,3 +1,3 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 bar = "BAR FROM sub/bar/bar.py" --- a/test/integration/targets/pause/test-pause.py +++ b/test/integration/targets/pause/test-pause.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import (absolute_import, division, print_function) __metaclass__ = type --- a/test/integration/targets/pip/files/setup.py +++ b/test/integration/targets/pip/files/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import (absolute_import, division, print_function) __metaclass__ = type --- a/test/integration/targets/service/files/ansible_test_service.py +++ b/test/integration/targets/service/files/ansible_test_service.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # this is mostly based off of the code found here: # http://code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/ --- a/test/integration/targets/template/role_filter/filter_plugins/myplugin.py +++ b/test/integration/targets/template/role_filter/filter_plugins/myplugin.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import (absolute_import, division, print_function) __metaclass__ = type --- a/test/integration/targets/throttle/test_throttle.py +++ b/test/integration/targets/throttle/test_throttle.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import (absolute_import, division, print_function) __metaclass__ = type --- a/test/integration/targets/var_precedence/ansible-var-precedence-check.py +++ b/test/integration/targets/var_precedence/ansible-var-precedence-check.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # A tool to check the order of precedence for ansible variables # https://github.com/ansible/ansible/blob/devel/test/integration/test_var_precedence.yml --- a/test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py +++ b/test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright: (c) 2020, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) --- a/test/integration/targets/builtin_vars_prompt/test-vars_prompt.py +++ b/test/integration/targets/builtin_vars_prompt/test-vars_prompt.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import (absolute_import, division, print_function) __metaclass__ = type --- a/test/integration/targets/cli/test_k_and_K.py +++ b/test/integration/targets/cli/test_k_and_K.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Make coding more python3-ish --- a/test/integration/targets/service_facts/files/ansible_test_service.py +++ b/test/integration/targets/service_facts/files/ansible_test_service.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # this is mostly based off of the code found here: # http://code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/ --- a/test/integration/targets/blocks/runme.sh +++ b/test/integration/targets/blocks/runme.sh @@ -9,7 +9,7 @@ rm -f block_test.out # run the test and check to make sure the right number of completions was logged ansible-playbook -vv main.yml -i ../../inventory | tee block_test.out -env python -c \ +env python3 -c \ 'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ block_test_wo_colors.out [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] @@ -17,7 +17,7 @@ rm -f block_test.out block_test_wo_colors.out # run test with free strategy and again count the completions ansible-playbook -vv main.yml -i ../../inventory -e test_strategy=free | tee block_test.out -env python -c \ +env python3 -c \ 'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ block_test_wo_colors.out [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] @@ -25,7 +25,7 @@ rm -f block_test.out block_test_wo_colors.out # run test with host_pinned strategy and again count the completions ansible-playbook -vv main.yml -i ../../inventory -e test_strategy=host_pinned | tee block_test.out -env python -c \ +env python3 -c \ 'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ block_test_wo_colors.out [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] @@ -33,7 +33,7 @@ # run test that includes tasks that fail inside a block with always rm -f block_test.out block_test_wo_colors.out ansible-playbook -vv block_fail.yml -i ../../inventory | tee block_test.out -env python -c \ +env python3 -c \ 'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ block_test_wo_colors.out [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] --- a/test/integration/targets/plugin_config_for_inventory/runme.sh +++ b/test/integration/targets/plugin_config_for_inventory/runme.sh @@ -7,12 +7,12 @@ # check default values ansible-inventory --list -i ./config_without_parameter.yml --export | \ - env python -c "import json, sys; inv = json.loads(sys.stdin.read()); \ + env python3 -c "import json, sys; inv = json.loads(sys.stdin.read()); \ assert set(inv['_meta']['hostvars']['test_host']['departments']) == set(['seine-et-marne', 'haute-garonne'])" # check values ansible-inventory --list -i ./config_with_parameter.yml --export | \ - env python -c "import json, sys; inv = json.loads(sys.stdin.read()); \ + env python3 -c "import json, sys; inv = json.loads(sys.stdin.read()); \ assert set(inv['_meta']['hostvars']['test_host']['departments']) == set(['paris'])" export ANSIBLE_CACHE_PLUGINS=cache_plugins/ --- a/test/units/modules/test_async_wrapper.py +++ b/test/units/modules/test_async_wrapper.py @@ -22,11 +22,11 @@ def test_run_module(self, monkeypatch): def mock_get_interpreter(module_path): - return ['/usr/bin/python'] + return ['/usr/bin/python3'] module_result = {'rc': 0} module_lines = [ - '#!/usr/bin/python', + '#!/usr/bin/python3', 'import sys', 'sys.stderr.write("stderr stuff")', "print('%s')" % json.dumps(module_result) --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ ASCII2MAN = @echo "ERROR: rst2man from docutils command is not installed but is required to build $(MANPAGES)" && exit 1 endif -PYTHON ?= python +PYTHON ?= python3 GENERATE_CLI = hacking/build-ansible.py generate-man # fetch version from project release.py as single source-of-truth --- a/docs/docsite/Makefile +++ b/docs/docsite/Makefile @@ -44,7 +44,7 @@ DOC_PLUGINS ?= become cache callback cliconf connection httpapi inventory lookup netconf shell strategy vars -PYTHON ?= python +PYTHON ?= python3 # fetch version from project release.py as single source-of-truth VERSION := $(shell $(PYTHON) ../../packaging/release/versionhelper/version_helper.py --raw || echo error) ifeq ($(findstring error,$(VERSION)), error)