Fix handling of shebangs

- Use new _py3_shebang_s macro
- Allow %pyproject_install to handle shebang fixing where appropriate
This commit is contained in:
Maxwell G 2022-10-27 13:29:19 -05:00
parent c33bf4a3b5
commit d03b7e96f1
No known key found for this signature in database
GPG Key ID: F79E4E25E8C661F8

View File

@ -108,8 +108,16 @@ This package includes shell completions files for ansible-core.
%prep
%autosetup -p1 -n ansible-%{version}
find \( -name '.git_keep' -o -name '.rstcheck.cfg' \) -delete
sed -i -s 's|/usr/bin/env python|%{python3}|' test/lib/ansible_test/_util/target/cli/ansible_test_cli_stub.py bin/*
sed -i -e '1{\@^#!.*@d}' lib/ansible/cli/*.py lib/ansible/modules/hostname.py lib/ansible/cli/scripts/ansible_connection_cli_stub.py
# ansible-test is executed directly by the Makefile, so we need to fix the shebang.
sed -i -s 's|/usr/bin/env python|%{python3}|' \
bin/ansible-test \
test/lib/ansible_test/_util/target/cli/ansible_test_cli_stub.py
# TODO: Investigate why hostname is the only module that still has a shebang
# and file an upstream issue if needed.
sed -i -e '1{\@^#!.*@d}' lib/ansible/modules/hostname.py
%generate_buildrequires
temp=$(mktemp)
@ -118,11 +126,7 @@ sed '/^mock$/d' test/lib/ansible_test/_data/requirements/units.txt > ${temp}
%build
# disable the python -s shbang flag as we want to be able to find non system modules
%global py3_shebang_flags %(echo %{py3_shebang_flags} | sed 's/s//')
%py3_shebang_fix .
# Build manpages
make PYTHON=%{python3} docs
%undefine _py3_shebang_s
%pyproject_wheel