File python-psutil.spec of Package python-psutil

#
# spec file for package python-psutil
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 this 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/
#


%global srcname psutil
%global sum A process and system utilities module for Python
%global python3_pkgversion 3

# Filter Python modules from Provides
%global __provides_exclude_from ^(%{python2_sitearch}|%{python3_sitearch})/.*\\.so$

Name:           python-%{srcname}
Version:        5.4.3
Release:        7%{?dist}
Summary:        %{sum}
License:        BSD-3-Clause

URL:            https://github.com/giampaolo/psutil
Source0:        https://github.com/giampaolo/psutil/archive/release-%{version}.tar.gz#/%{srcname}-%{version}.tar.gz
#
# Disable upstream failing test
# https://github.com/giampaolo/psutil/issues/946
#
#Patch0:         psutil-5.4.3-disable-broken-tests.patch

BuildRequires:  gcc
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python2-devel
# Test dependencies
BuildRequires:  procps-ng
BuildRequires:  python%{python3_pkgversion}-mock
BuildRequires:  python2-ipaddress
BuildRequires:  python2-mock

%description
psutil is a module providing an interface for retrieving information on all
running processes and system utilization (CPU, memory, disks, network, users) in
a portable way by using Python, implementing many functionalities offered by
command line tools such as: ps, top, df, kill, free, lsof, free, netstat,
ifconfig, nice, ionice, iostat, iotop, uptime, pidof, tty, who, taskset, pmap.


%package -n python2-%{srcname}
Summary:        %{sum}
%{?python_provide:%python_provide python2-%{srcname}}
Obsoletes:      python-%{srcname} < 3.1.1-3

%description -n python2-psutil
psutil is a module providing an interface for retrieving information on all
running processes and system utilization (CPU, memory, disks, network, users) in
a portable way by using Python 3, implementing many functionalities offered by
command line tools such as: ps, top, df, kill, free, lsof, free, netstat,
ifconfig, nice, ionice, iostat, iotop, uptime, pidof, tty, who, taskset, pmap.

%package -n python%{python3_pkgversion}-psutil
Summary:        %{sum}
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}

%description -n python%{python3_pkgversion}-psutil
psutil is a module providing an interface for retrieving information on all
running processes and system utilization (CPU, memory, disks, network, users) in
a portable way by using Python 3, implementing many functionalities offered by
command line tools such as: ps, top, df, kill, free, lsof, free, netstat,
ifconfig, nice, ionice, iostat, iotop, uptime, pidof, tty, who, taskset, pmap.


%prep
%autosetup -p0 -n %{srcname}-release-%{version}

# Remove shebangs
find psutil -name \*.py | while read file; do
  sed -i.orig -e '1{/^#!/d}' $file && \
  touch -r $file.orig $file && \
  rm $file.orig
done

%build
%py2_build
%py3_build

%install
%py2_install
%py3_install

#%check
# the main test target causes failures, investigating
#make test-memleaks PYTHON=%{__python2}
#make test-memleaks PYTHON=%{__python3}

%files -n python2-%{srcname}
%license LICENSE
%doc CREDITS HISTORY.rst README.rst
%{python2_sitearch}/%{srcname}/
%{python2_sitearch}/*.egg-info

%files -n python%{python3_pkgversion}-%{srcname}
%license LICENSE
%doc CREDITS HISTORY.rst README.rst
%{python3_sitearch}/%{srcname}/
%{python3_sitearch}/*.egg-info

%changelog
openSUSE Build Service is sponsored by