Blob Blame History Raw
%if 0%{?fedora}
%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:        2%{?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 python3-%{srcname}
Summary:        %{sum}
BuildRequires:  python3-devel
BuildRequires:  python3-pytest
%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-%{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
# Must do the python2 install first because the scripts in /usr/bin are
# overwritten with every setup.py install, and in general we want the
# python3 version to be the default.
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_sitelib} py.test-%{python2_version} -vv
%if 0%{?with_python3}
PYTHONPATH=%{buildroot}%{python3_sitelib} 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 python3-%{srcname}
%license LICENSE
%doc CHANGELOG README.rst
%{python3_sitearch}/*
%endif

%changelog
* 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