Drop optional build dependency on python2-setuptools

While we are on version 5.8.0 we need egg-info to remain a directory,
so we copy paste the Python 3 egg-info directory.

However, it is temporary. Once the version is updated, we can get rid of it.
This commit is contained in:
Miro Hrončok 2021-06-23 19:20:27 +02:00
parent 6b565402a2
commit b11f8dc358
1 changed files with 31 additions and 13 deletions

View File

@ -3,7 +3,7 @@
Name: python-%{srcname}
Version: 5.8.0
Release: 7%{?dist}
Release: 8%{?dist}
Summary: %{sum}
License: BSD
@ -17,25 +17,18 @@ Patch0: python-psutil-skip-tests-in-mock.patch
# Add tolerance to psutil.tests.test_linux.TestSystemVirtualMemory.test_total
Patch1: https://github.com/giampaolo/psutil/pull/1935.patch#/python-psutil-add-tolerance.patch
BuildRequires: make
BuildRequires: gcc
BuildRequires: grep
BuildRequires: make
BuildRequires: python%{python3_pkgversion}-devel
# Test dependencies
BuildRequires: procps-ng
BuildRequires: python%{python3_pkgversion}-setuptools
%if 0%{?fedora} < 32 && 0%{?rhel} < 9
BuildRequires: python2-mock
BuildRequires: python2-devel
BuildRequires: python2-ipaddress
BuildRequires: python2-setuptools
%else
# This package has an exception to use Python 2 in Fedora 32+
# The exception is for chromium (chrome-remote-desktop)
# https://pagure.io/fesco/issue/2214
BuildRequires: python27
BuildRequires: python2-setuptools
%endif
BuildRequires: python2.7
%description
psutil is a module providing an interface for retrieving information on all
@ -89,26 +82,51 @@ done
%py2_install
%py3_install
# %%python2_egg_path was a directory in previous builds, because setuptools were used.
# Before the version is bumped and this path changed, we need to preserve the directory to avoid:
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Directory_Replacement/
%global python2_egg_path %{python2_sitearch}/%{srcname}-%{version}-py%{python2_version}.egg-info
%global python3_egg_path %{python3_sitearch}/%{srcname}-%{version}-py%{python3_version}.egg-info
%if "%{version}" == "5.8.0"
rm %{buildroot}%{python2_egg_path}
cp -a %{buildroot}%{python3_egg_path} %{buildroot}%{python2_egg_path}
# if this grep fails, we have a new metadata version and we need to manually check if Python 2 can still understand it
grep '^Metadata-Version: 2\.1$' %{buildroot}%{python2_egg_path}/PKG-INFO
%endif
%check
make test CI_TESTING=1 PYTHON=%{__python3} PYTHONPATH=%{buildroot}/%{python3_sitearch}
%if "%{version}" == "5.8.0"
# assert the Python 2 egg info is a directory to preserve upgrade path
test -d %{buildroot}%{python2_egg_path}
%else
# assert the Python 2 egg info is *not* a directory to be able to eventually
# drop all the egg-info directory mangling from this spec
test -f %{buildroot}%{python2_egg_path}
%endif
%files -n python2-%{srcname}
%license LICENSE
%doc CREDITS HISTORY.rst README.rst
%{python2_sitearch}/%{srcname}/
%{python2_sitearch}/*.egg-info
%{python2_egg_path}
%files -n python%{python3_pkgversion}-%{srcname}
%license LICENSE
%doc CREDITS HISTORY.rst README.rst
%{python3_sitearch}/%{srcname}/
%{python3_sitearch}/*.egg-info
%{python3_egg_path}/
%changelog
* Wed Jun 23 2021 Miro Hrončok <mhroncok@redhat.com> - 5.8.0-8
- Drop optional build dependency on python2-setuptools
* Wed Jun 02 2021 Python Maint <python-maint@redhat.com> - 5.8.0-7
- Rebuilt for Python 3.10