# Tests by default. No tests: rpm -ba --define 'dotests 0' *.spec
#%{!?dotests: %define dotests 1}

%define name python3-coverage
%define srcname coverage
%define version 4.5.4
%define release 1

%define is_python %(test -e /usr/bin/python3_32 && echo 1 || echo 0)
%if %{is_python}
%define python_sitelib %(python3_32 -c "from distutils.sysconfig import get_python_lib; print (get_python_lib(1))")
%endif

%define _libdir64 %{_prefix}/lib64

%define is_python_64 %(test -e /usr/bin/python3 && echo 1 || echo 0)
%if %{is_python_64}
%define python_sitelib64 %(python3 -c "from distutils.sysconfig import get_python_lib; print (get_python_lib(1))")
%endif

Summary: Code coverage measurement for Python
Name: %{name}
Version: %{version}
Release: %{release}
Source0: %{srcname}-%{version}.tar.gz
License: BSD
Group: Development/Libraries
BuildRequires: python, python-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Prefix: %{_prefix}
Vendor: Ned Batchelder and others <ned@nedbatchelder.com>
Url: http://nedbatchelder.com/code/coverage
Requires: python3

%description
Coverage.py measures code coverage, typically during test execution. It uses
the code analysis tools and tracing hooks provided in the Python standard
library to determine which lines are executable, and which have been executed.

%prep
%setup -n %{srcname}-%{version}

%build
export OBJECT_MODE=64
python3 setup.py build

#if [ "%{dotests}" == 1 ]
#then
#python3 setup.py test
#fi


%install
[ -d "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT

python3 setup.py install --skip-build --root ${RPM_BUILD_ROOT}


cd ${RPM_BUILD_ROOT}
mkdir -p usr/bin
cd usr/bin
ln -sf ../..%{_bindir}/* .

%clean
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(-,root,system,-)
%doc  CHANGES.rst PKG-INFO README.rst doc
%{_bindir}/*
/usr/bin/*
%{python_sitelib64}/*

%changelog
* Fri Nov 8 2019 Harshita Jain <harjain9@in.ibm.com> - 4.5.4-1
- Update the latest version
- Build with python3

* Thu Jun 7 2013 Tristan Delhalle <Tristan.Delhalle@ext.bull.net> - 3.6-1
- first version for AIX V6.1 and higher
