Blob Blame History Raw
%if 0%{?fedora} || 0%{?rhel} >= 7
%global with_python3 1
%endif

%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%{!?python2_version: %global python2_version %(%{__python2} -c "import sys; sys.stdout.write(sys.version[:3])")}
%endif

%global srcname pycosat
%global sum Python bindings to picosat (a SAT solver)
%global pkgdesc \
PicoSAT is a popular SAT solver written by Armin Biere in pure C. This \
package provides efficient Python bindings to picosat on the C level, i.e. \
when importing pycosat, the picosat solver becomes part of the Python process \
itself.

Name:           python-%{srcname}
Version:        0.6.1
Release:        8%{?dist}
Summary:        %{sum}

License:        MIT
URL:            http://pypi.python.org/pypi/%{srcname}
Source0:        http://pypi.python.org/packages/source/p/%{srcname}/%{srcname}-%{version}.tar.gz

BuildRequires:  picosat-devel

%description
%{pkgdesc}

%package -n python2-%{srcname}
Summary:        %{sum}
BuildRequires:  python2-devel
BuildRequires:  pytest
%{!?python_provide:Provides: python-%{srcname} = %{version}-%{release}}
%{?python_provide:%python_provide python2-%{srcname}}

%description -n python2-%{srcname}
%{pkgdesc}


%if 0%{?with_python3}
%package -n python%{python3_pkgversion}-%{srcname}
Summary:        %{sum}
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-pytest
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}

%description -n python%{python3_pkgversion}-%{srcname}
%{pkgdesc}
%endif


%prep
%setup -q -n %{srcname}-%{version}
sed -i -e s/distutils.core/setuptools/ setup.py
rm picosat.*

%build
CFLAGS="%{optflags}" %{__python2} setup.py build_ext --inplace
%if 0%{?with_python3}
CFLAGS="%{optflags}" %{__python3} setup.py build_ext --inplace
%endif

%install
CFLAGS="%{optflags}" %{__python2} setup.py install -O1 --skip-build --root %{buildroot}
%if 0%{?with_python3}
#py3_install
CFLAGS="%{optflags}" %{__python3} setup.py install -O1 --skip-build --root %{buildroot}
%endif

%check
PYTHONPATH=%{buildroot}%{python2_sitearch} py.test-%{python2_version} -vv
%if 0%{?with_python3}
PYTHONPATH=%{buildroot}%{python3_sitearch} py.test-%{python3_version} -vv
%endif

%files -n python2-%{srcname}
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc CHANGELOG README.rst
%{python2_sitearch}/*

%if 0%{?with_python3}
%files -n python%{python3_pkgversion}-%{srcname}
%license LICENSE
%doc CHANGELOG README.rst
%{python3_sitearch}/*
%endif

%changelog
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.1-8
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Tue Apr 19 2016 Orion Poplawski <orion@cora.nwra.com> - 0.6.1-7
- Build python3 packages for EPEL7

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Jan 13 2016 Jerry James <loganjerry@gmail.com> - 0.6.1-5
- Rebuild for picosat 965

* Sun Jan 3 2016 Orion Poplawski <orion@cora.nwra.com> - 0.6.1-4
- Fix PYTHONPATH in %%check

* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.1-3
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5

* Tue Sep 22 2015 Orion Poplawski <orion@cora.nwra.com> - 0.6.1-2
- Quiet setup

* Mon Sep 21 2015 Orion Poplawski <orion@cora.nwra.com> - 0.6.1-1
- Initial package