From c98092b2214a4c0c23111593ecf66a9d4f739adf Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Thu, 20 Apr 2023 20:47:22 +0000 Subject: [PATCH] account for the removed Makefile --- ansible-core.spec | 18 ++++++++++++------ build_manpages.py | 27 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 build_manpages.py diff --git a/ansible-core.spec b/ansible-core.spec index f546679..e4e99c9 100644 --- a/ansible-core.spec +++ b/ansible-core.spec @@ -11,7 +11,8 @@ Release: 2%{?dist} # are BSD licensed. There are various files scattered throughout the codebase # containing code under different licenses. License: GPL-3.0-or-later AND BSD-2-Clause AND PSF-2.0 AND MIT AND Apache-2.0 -Source: https://github.com/ansible/ansible/archive/v%{uversion}/%{name}-%{uversion}.tar.gz +Source0: https://github.com/ansible/ansible/archive/v%{uversion}/%{name}-%{uversion}.tar.gz +Source1: build_manpages.py Url: https://ansible.com BuildArch: noarch @@ -48,7 +49,6 @@ Obsoletes: ansible-base < 2.10.6-1 BuildRequires: make BuildRequires: python%{python3_pkgversion}-devel # Needed to build manpages from source. -BuildRequires: python%{python3_pkgversion}-straight-plugin BuildRequires: python%{python3_pkgversion}-docutils # Shell completions BuildRequires: python%{python3_pkgversion}-argcomplete @@ -95,7 +95,6 @@ This package installs extensive documentation for ansible-core %autosetup -p1 -n ansible-%{uversion} find \( -name '.git_keep' -o -name '.rstcheck.cfg' \) -delete -# 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 @@ -116,7 +115,13 @@ sed '/^mock$/d' test/lib/ansible_test/_data/requirements/units.txt > _requiremen %pyproject_wheel # Build manpages -make PYTHON=%{python3} docs + +# XXX: This should be removed once upstream provides a proper way to build +# manpages from source. +# See https://github.com/ansible/ansible/issues/80368 +# and the discussion in https://github.com/ansible/ansible/pull/80372 +# for more details. +PYTHONPATH="$(pwd)/packaging" %{python3} %{S:1} # Build shell completions ( @@ -215,8 +220,8 @@ install -Dpm 0644 licenses/* -t %{buildroot}%{_pkglicensedir} %check %if %{with tests} -ln -s /usr/bin/pytest-3 bin/pytest -make PYTHON=%{python3} tests-py3 +%{python3} bin/ansible-test \ + units --local --python-interpreter %{python3} %endif @@ -242,6 +247,7 @@ make PYTHON=%{python3} tests-py3 %changelog * Mon Apr 24 2023 Maxwell G - 2.15.0~b3-1 - Update to 2.15.0~b3. +- Account for the removed Makefile * Mon Apr 24 2023 Maxwell G - 2.14.4-2 - Add gating diff --git a/build_manpages.py b/build_manpages.py new file mode 100644 index 0000000..e733cd2 --- /dev/null +++ b/build_manpages.py @@ -0,0 +1,27 @@ +# Copyright (C) Ansible Project +# +# SPDX-License-Identifier: GPL-3.0-or-later + +from pathlib import Path + +from pep517_backend._backend import ( + _convert_rst_in_template_to_manpage, + _generate_rst_in_templates, + _get_package_distribution_version, +) + + +def main(): + Path('docs/man/man1/').mkdir(exist_ok=True, parents=True) + version_number = _get_package_distribution_version() + for rst_in in _generate_rst_in_templates(): + _convert_rst_in_template_to_manpage( + rst_doc_template=rst_in.read_text(), + destination_path=rst_in.with_suffix('').with_suffix(''), + version_number=version_number, + ) + rst_in.unlink() + + +if __name__ == "__main__": + main()