File ansible-variables.spec of Package failed_ansible-variables

#
# spec file for package ansible-variables
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for the file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%{?sle15_python_module_pythons}
# Ensure rpmbuild uses Python 3.11 binary for helper macros invoked by
# python-rpm-macros (which otherwise picks system python, e.g. python3.13).
%global __python3 /usr/bin/python3.11
%global __python /usr/bin/python3.11
%define pythons python311
%define ansible_python python311
%define ansible_python_executable python3.11
%define ansible_python_sitelib %python311_sitelib
%if 0%{?suse_version} < 1550
# Leap15, SLES15
%if %pythons == "python310"
%define ansible_python python310
%define ansible_python_executable python3.10
%define ansible_python_sitelib %python310_sitelib
%endif
%if %pythons == "python311"
%define ansible_python python311
%define ansible_python_executable python3.11
%define ansible_python_sitelib %python311_sitelib
%endif
%else
# Tumbleweed
# Use a concrete Python that is supported by the package (>=3.8,<3.13)
# to avoid building with the system python (e.g. 3.13) which is not
# accepted by the package's pyproject metadata.
%define pythons python311
%define ansible_python python311
%define ansible_python_executable python3.11
%define ansible_python_sitelib %python311_sitelib
%endif

Name:           ansible-variables
Version:        0.8.1
Release:        0
Summary:        Tool to show origin of Ansible host context variables
License:        GPL-3.0-or-later
URL:            https://github.com/hille721/ansible-variables
# the PyPI tarball does not contain all files required for the tests
Source:         https://github.com/hille721/ansible-variables/archive/v%{version}/ansible-variables-%{version}.tar.gz#/ansible-variables-%{version}.tar.gz
BuildRequires:  %{ansible_python}-pip
BuildRequires:  %{ansible_python}-setuptools
BuildRequires:  %{ansible_python}-wheel
BuildRequires:  python-rpm-macros
# SECTION test requirements
BuildRequires:  ansible-core >= 2.12.0
BuildRequires:  %{ansible_python}-pytest
BuildRequires:  %{ansible_python}-rich
# /SECTION
BuildRequires:  fdupes
Requires:       %{ansible_python}-rich
Requires:       ansible-core >= 2.12.0
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch:      noarch

%description
The Ansible inventory is a framework for declaring variables in a
hierarchical manner. There a lot of different places where a variable
can be defined. ansible-variables displays where host context
variables originate from.

%prep
%autosetup -p1 -n ansible-variables-%{version}

%build
# Build the wheel using the selected ansible Python interpreter to avoid
# using the system default (e.g. python3.13) which is incompatible with
# the package's requires-python (>=3.8,<3.13).
%{ansible_python_executable} -m pip wheel . -w dist --no-deps

%install
# Install the built wheel into the buildroot using the same interpreter.
%{ansible_python_executable} -m pip install --root=%{buildroot} --no-deps dist/*.whl
%python_clone -a %{buildroot}%{_bindir}/ansible-variables
# expand fdupes into the correct ansible python site lib in the buildroot
%python_expand %fdupes %{buildroot}%{ansible_python_sitelib}

%check
export PATH="%{buildroot}%{_bindir}:$PATH"
%{ansible_python_executable} -m pytest

%post
%python_install_alternative ansible-variables

%postun
%python_uninstall_alternative ansible-variables

%files
%doc README.md
%license LICENSE
%python_alternative %{_bindir}/ansible-variables
%{ansible_python_sitelib}/ansible_variables
%{ansible_python_sitelib}/ansible_variables-%{version}.dist-info

%changelog
openSUSE Build Service is sponsored by