From 7d72aaaff07cbfbe30e65a44932288b4ae561909 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Tue, 28 Jun 2016 11:12:48 +0200
Subject: [PATCH] New upstream and Python2/3 subpackages.

---
 python-cassandra-driver.spec | 121 +++++++++++++++++++++++++++++++------------
 1 file changed, 87 insertions(+), 34 deletions(-)

diff --git a/python-cassandra-driver.spec b/python-cassandra-driver.spec
index 2331287..9737122 100644
--- a/python-cassandra-driver.spec
+++ b/python-cassandra-driver.spec
@@ -1,49 +1,81 @@
 %global __provides_exclude_from ^%{python2_sitearch}/cassandra/io/.*\\.so$
-%global commit 840064a9e27929c5f44ba06b72bfc3e69d905ee6
-
-Name:           python-cassandra-driver
-Version:        1.1.1
-Release:        8%{?dist}
-Summary:        DataStax Python Driver for Apache Cassandra
-
+# Enable/disable tests
+%global with_tests 0
+
+%global srcname python-driver
+%global pypi_name cassandra-driver
+%global desc A modern, feature-rich and highly-tunable Python client library for\
+Apache Cassandra (1.2+) and DataStax Enterprise (3.1+) using exclusively\
+Cassandra's binary protocol and Cassandra Query Language v3.\
+%global sum Python driver for Cassandra
+
+Name:           python-%{pypi_name}
+Version:        3.4.1
+Release:        1%{?dist}
+Summary:        %{sum}
 Group:          Development/Libraries
-License:        ASL 2.0 and MIT
-URL:            https://github.com/datastax/python-driver
-Source0:        https://github.com/datastax/python-driver/archive/%{commit}/python-driver-%{commit}.tar.gz
+License:        ASL 2.0
+URL:            https://github.com/datastax/%{srcname}
+Source0:        https://github.com/datastax/%{srcname}/archive/%{version}.tar.gz
 
-# Not upstreamable
-Patch0:         0001-Remove-unnecessary-test-dependencies.patch
+BuildRequires:  libev
+BuildRequires:  libev-devel
 
-BuildRequires:  python2-devel
-BuildRequires:  python-setuptools
+BuildRequires:  Cython
 BuildRequires:  python-futures
-BuildRequires:  python-scales
-BuildRequires:  python-blist
-BuildRequires:  python-nose
+BuildRequires:  python-setuptools
+BuildRequires:  python2-devel
+
+BuildRequires:  python3-Cython
+BuildRequires:  python3-setuptools
+BuildRequires:  python3-devel
+
+# Tests build dependencies
+%if 0%{?with_tests}
 BuildRequires:  python-mock
-BuildRequires:  libev-devel
+BuildRequires:  python-nose
 
-Requires:       python-futures
-Requires:       python-scales
-Requires:       python-blist
+BuildRequires:  python3-mock
+BuildRequires:  python3-nose
+%endif # with_tests
 
 %description
-A Python client driver for Apache Cassandra. This driver works exclusively
-with the Cassandra Query Language v3 (CQL3) and Cassandra's native protocol.
-As such, only Cassandra 1.2+ is supported.
+%{desc}
 
+%package doc
+Summary:        Documentation for %{pypi_name}
 
-%prep
-%setup -q -n python-driver-%{commit}
-%patch0 -p1
+%description doc
+This package provides the documentation for python-%{pypi_name}.
 
 
-%build
-CFLAGS="%{optflags}" %{__python2} setup.py build
+%package -n python2-%{pypi_name}
+Summary:        %{sum}
+%{?python_provide:%python_provide python2-%{pypi_name}}
+Requires:       python-six >= 1.6
 
+%description -n python2-%{pypi_name}
+%{desc}
+
+
+%package -n python3-%{pypi_name}
+Summary:        %{sum}
+%{?python_provide:%python_provide python3-%{pypi_name}}
+Requires:       python3-six >= 1.6
+
+%description -n python3-%{pypi_name}
+%{desc}
+
+%prep
+%setup -q -n %{srcname}-%{version}
+
+%build
+%{py2_build}
+%{py3_build}
 
 %install
-%{__python2} setup.py install --skip-build --root %{buildroot}
+%{py2_install}
+%{py3_install}
 
 # "The optional C extensions are not supported on big-endian systems."
 # ...which causes setup.py to install it into arch-agnostic directory,
@@ -58,25 +90,46 @@ mv %{buildroot}{%{python2_sitelib}/*,%{python2_sitearch}}
 chmod 0755 %{buildroot}%{python2_sitearch}/cassandra/{io/,}*.so
 %endif
 
-
+%if 0%{?with_tests}
 %check
 # Just running the unit tests. Integration tests need ccm and cassandra
 # running (neither shipped with Fedora)
-%{__python2} setup.py nosetests --tests tests/unit/ \
+%{__python2} -m nose tests/unit/ \
+%ifnarch x86_64
+|| :
+%endif
+
+%{__python3} -m nose tests/unit/ \
 %ifnarch x86_64
 || :
 %endif
+%endif # with_tests
 
+%files doc
+%doc docs/*
 
-%files
+%files -n python2-%{pypi_name}
 %{python2_sitearch}/cassandra/
 %exclude %{python2_sitearch}/cassandra/*.c
 %exclude %{python2_sitearch}/cassandra/*/*.c
 %{python2_sitearch}/cassandra*.egg-info/
-%doc CHANGELOG.rst README.rst LICENSE example.py
+%doc CHANGELOG.rst README.rst example_core.py example_mapper.py
+%license LICENSE
 
+%files -n python3-%{pypi_name}
+%{python3_sitearch}/cassandra/
+%exclude %{python3_sitearch}/cassandra/*.c
+%exclude %{python3_sitearch}/cassandra/*/*.c
+%{python3_sitearch}/cassandra*.egg-info/
+%doc CHANGELOG.rst README.rst example_core.py example_mapper.py
+%license LICENSE
 
 %changelog
+* Wed Jun 22 2016 Lumir Balhar <lbalhar@redhat.com> - 3.4.1-1
+- New upstream release
+- Python 2/3 subpackages
+- Disabled tests - unresolvable dependencies
+
 * Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-8
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
 
-- 
2.7.4

