Unknown tag: %python_provide: ERROR: python3-ansible not recognized

Viewed 175

I dont know what the following error means. According to this link the %python_provide tag should be valid

[root@ip-10-114-62-15 ~]# rpmbuild -ba rpmbuild/SPECS/ansible.spec 
error: line 29: Unknown tag: %python_provide: ERROR: python3-ansible not recognized.
[root@ip-10-114-62-15 ~]# cat rpmbuild/SPECS/ansible.spec 
# Created by pyp2rpm-3.3.7
%global pypi_name ansible
%global pypi_version 4.5.0
%global pypi_source ansible-4.5.0.tar.gz
Name:           python-%{pypi_name}
Version:        %{pypi_version}
Release:        1%{?dist}
Summary:        Radically simple IT automation

License:        GPLv3+
URL:            https://ansible.com/
Source0:        %{pypi_source}

BuildRequires:  python3-devel
BuildRequires:  python3dist(ansible-core) >= 2.11.4 with python3dist(ansible-core) < 2.12
BuildRequires:  python3dist(setuptools)
BuildRequires:  python3dist(sphinx)

%description
|PyPI version| |Docs badge| |Chat badge| |Build Status| |Code Of Conduct|
|Mailing Lists| |License|**************Ansible is a radically simple IT
automation system. It handles configuration management, application deployment,
cloud provisioning, ad-hoc task execution, network automation, and multi-node
orchestration. Ansible makes complex changes like zero-downtime rolling updates
with load...

%package -n     python3-%{pypi_name}
Summary:        %{summary}
%{?python_provide:%python_provide python3-%{pypi_name}}

Requires:       (python3dist(ansible-core) >= 2.11.4 with python3dist(ansible-core) < 2.12)
%description -n python3-%{pypi_name}
|PyPI version| |Docs badge| |Chat badge| |Build Status| |Code Of Conduct|
|Mailing Lists| |License|**************Ansible is a radically simple IT
automation system. It handles configuration management, application deployment,
cloud provisioning, ad-hoc task execution, network automation, and multi-node
orchestration. Ansible makes complex changes like zero-downtime rolling updates
with load...

%package -n python-%{pypi_name}-doc
Summary:        ansible documentation
%description -n python-%{pypi_name}-doc
Documentation for ansible

%prep
%autosetup -n %{pypi_name}-%{pypi_version}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info

%build
%py3_build
# generate html docs
PYTHONPATH=${PWD} sphinx-build-3 ansible_collections/sensu/sensu_go/docs/source html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}

%install
%py3_install

%check
%{__python3} setup.py test

1 Answers

Little information was given, but I would assume you are trying to build on CentOS/RHEL 8 machine, where macro %python_provide requires another, %{python3_pkgversion}. E.g. the source for the former is:

%python_provide() %{lua:
  function string.starts(String,Start)
    return string.sub(String,1,string.len(Start))==Start
  end
  package = rpm.expand("%{?1}")
  vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}")
  if (string.starts(package, "python2-")) then
    --No unversioned provides as python2 is not default
  elseif (string.starts(package, "python" .. rpm.expand("%{python3_pkgversion}") .. "-")) then
    --No unversioned provides as python3 is not default
  elseif (rpm.expand("%{?python3_other_pkgversion}") ~= "" and string.starts(package, "python" .. rpm.expand("%{python3_other_pkgversion}") .. "-")) then
    --No unversioned provides as python3_other is not default
  elseif (string.starts(package, "pypy-")) then
    --No unversioned provides as pypy is not default
  elseif (string.starts(package, "pypy3-")) then
    --No unversioned provides as pypy is not default
  elseif (string.starts(package, "python-")) then
    --Providing the current default python
    print("Provides: python2-")
    print(string.sub(package,8,string.len(package)))
    print(" = ")
    print(vr)
  else
    print("%python_provide: ERROR: ")
    print(package)
    print(" not recognized.")
  end
}

So the only way the python3-ansible can error when going through it is when %{python3_pkgversion} is undefined.

You probably want to install python-srpm-macros package...

Related