%{!?python3_sitearch: %global python3_sitearch %(python3 -c "from distutils.sysconfig import get_python_lib; import sys; sys.stdout.write(get_python_lib(1))")}
%{!?python3_sitelib: %global python3_sitelib %(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python3_version: %global python3_version %(python3 -c "import sys; sys.stdout.write(sys.version[:3])")}

%global python3_pkgversion 3

%global sqlite_version 3.8.8.2
%global uprel 1
%global pkg_version %{sqlite_version}-r%{uprel}

%global real_version %(eval echo %{pkg_version} | %{__sed} 's/-/./')

#filter_provides_in %{python_sitearch}/.*\.so$ 
#filter_provides_in %{python3_sitearch}/.*\.so$ 
#filter_setup

%global __requires_exclude_from (%{python_sitearch}|%{python3_sitearch})/.*\.so$

Name:               python-apsw
Version:            %{real_version}
Release:            1%{?_dist_release}
Summary:            Another Python SQLite Wrapper
Group:              Development/Libraries
License:            zlib
URL:                https://github.com/rogerbinns/apsw
Source:             https://github.com/rogerbinns/apsw/releases/download/%{pkg_version}/apsw-%{pkg_version}.tar.gz

Provides:           python2-apsw

BuildRequires:      python-devel
BuildRequires:      python%{python3_pkgversion}-devel
BuildRequires:      sqlite3-devel

Requires:           sqlite3

%description
APSW is a Python wrapper for the SQLite embedded relational database
engine. In contrast to other wrappers such as pysqlite it focuses on
being a minimal layer over SQLite attempting just to translate the
complete SQLite API into Python.

%package -n python%{python3_pkgversion}-apsw
Summary:            Another Python SQLite Wrapper
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}

%description -n python%{python3_pkgversion}-apsw
APSW is a Python %{python3_version} wrapper for the SQLite embedded relational database
engine. In contrast to other wrappers such as pysqlite it focuses on
being a minimal layer over SQLite attempting just to translate the
complete SQLite API into Python.

%prep
%autosetup -n apsw-%{pkg_version}
rm -f doc/.buildinfo

%build
CFLAGS="%{optflags}" %{__python} setup.py build
CFLAGS="%{optflags}" python3 setup.py build

%install
CFLAGS="%{optflags}" %{__python} setup.py install \
    --skip-build --root %{buildroot}
CFLAGS="%{optflags}" python3 setup.py install \
    --skip-build --root %{buildroot}

%check
:

%files
%doc doc/*
%{python_sitearch}/apsw*.so
%{python_sitearch}/apsw*.egg-info

%files -n python%{python3_pkgversion}-apsw
%doc doc/*
%{python3_sitearch}/apsw*.so
%{python3_sitearch}/apsw*.egg-info


%changelog
* Mon Jul 11 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 3.8.8.2.r1-4
- initial build for Vine Linux.
