Switch to pyproject-rpm-macros

This is part of the specs modernization effort, following the Fedora
recomendations [1].

[1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/

Change-Id: Ic52d7566b9de061236582a5b37796ad2c3492a9a
diff --git a/python-kuryr-tests-tempest.spec b/python-kuryr-tests-tempest.spec
index c81a2b5..927b2d4 100644
--- a/python-kuryr-tests-tempest.spec
+++ b/python-kuryr-tests-tempest.spec
@@ -6,6 +6,12 @@
 %global with_doc 1
 
 %{!?upstream_version: %global upstream_version %{version}%{?milestone}}
+# we are excluding some BRs from automatic generator
+%global excluded_brs doc8 bandit pre-commit hacking flake8-import-order bashate pylint
+# Exclude sphinx from BRs if docs are disabled
+%if ! 0%{?with_doc}
+%global excluded_brs %{excluded_brs} sphinx openstackdocstheme
+%endif
 
 %global common_desc \
 This package contains Tempest tests to cover the kuryr-kubernetes project. \
@@ -15,7 +21,7 @@
 Version:    XXX
 Release:    XXX
 Summary:    Tempest Integration of Kuryr and Kuryr-Kubernetes
-License:    ASL 2.0
+License:    Apache-2.0
 URL:        https://git.openstack.org/cgit/openstack/%{plugin}/
 
 Source0:    http://tarballs.openstack.org/%{plugin}/%{plugin}-%{upstream_version}.tar.gz
@@ -40,23 +46,8 @@
 
 %package -n python3-%{service}-tests-tempest
 Summary: %{summary}
-%{?python_provide:%python_provide python3-%{service}-tests-tempest}
 BuildRequires:  python3-devel
-BuildRequires:  python3-pbr
-BuildRequires:  python3-setuptools
-BuildRequires:  python3-reno
-
-Requires:   python3-pbr >= 3.1.1
-Requires:   python3-six >= 1.10.0
-Requires:   python3-tempest >= 1:18.0.0
-Requires:   python3-testrepository >= 0.0.20
-Requires:   python3-oslotest >= 1.10.0
-Requires:   python3-os-testr >= 0.8.0
-Requires:   python3-testtools >= 1.8.0
-Requires:   python3-kubernetes >= 5.0.0
-Requires:   python3-openshift >= 0.7.0
-Requires:   python3-oslo-concurrency >= 3.26.0
-Requires:   python3-netaddr >= 0.7.19
+BuildRequires:  pyproject-rpm-macros
 
 %description -n python3-%{service}-tests-tempest
 %{common_desc}
@@ -65,9 +56,6 @@
 %package -n python-%{service}-tests-tempest-doc
 Summary:        python-%{service}-tests-tempest documentation
 
-BuildRequires:  python3-sphinx
-BuildRequires:  python3-openstackdocstheme
-
 %description -n python-%{service}-tests-tempest-doc
 It contains the documentation for the kuryr tempest plugin.
 %endif
@@ -79,29 +67,47 @@
 %endif
 %autosetup -n %{plugin}-%{upstream_version} -S git
 
-# Let's handle dependencies ourseleves
-%py_req_cleanup
-# Remove bundled egg-ingo
-rm -rf %{module}.egg-info
+
+sed -i /^[[:space:]]*-c{env:.*_CONSTRAINTS_FILE.*/d tox.ini
+sed -i "s/^deps = -c{env:.*_CONSTRAINTS_FILE.*/deps =/" tox.ini
+sed -i /^minversion.*/d tox.ini
+sed -i /^requires.*virtualenv.*/d tox.ini
+
+# Exclude some bad-known BRs
+for pkg in %{excluded_brs}; do
+  for reqfile in doc/requirements.txt test-requirements.txt; do
+    if [ -f $reqfile ]; then
+      sed -i /^${pkg}.*/d $reqfile
+    fi
+  done
+done
+
+# Automatic BR generation
+%generate_buildrequires
+%if 0%{?with_doc}
+  %pyproject_buildrequires -t -e docs
+%else
+  %pyproject_buildrequires -R
+%endif
 
 %build
-%{py3_build}
+%pyproject_wheel
 
 # Generate Docs
 %if 0%{?with_doc}
-sphinx-build -W -b html doc/source doc/build/html
+%tox -e docs
 # remove the sphinx build leftovers
 rm -rf doc/build/html/.{doctrees,buildinfo}
 %endif
 
 %install
-%{py3_install}
+%pyproject_install
 
 %files -n python3-%{service}-tests-tempest
 %license LICENSE
 %doc README.rst
 %{python3_sitelib}/%{module}
-%{python3_sitelib}/*.egg-info
+%{python3_sitelib}/*.dist-info
 
 %if 0%{?with_doc}
 %files -n python-%{service}-tests-tempest-doc