-# %bcond_without tests # do not perform "make test"
+#
+# Conditional build:
+%bcond_without tests # unit tests
+%bcond_without python2 # CPython 2.x module
+%bcond_without python3 # CPython 3.x module
-%define module msgpack
+%define module msgpack
+%define pypi_name msgpack-python
Summary: Binary-based efficient data interchange format
-Summary(pl.UTF-8): Binarny efektywny format wymiany danych.
+Summary(pl.UTF-8): Binarny, efektywny format wymiany danych
Name: python-%{module}
-Version: 0.2.0
+Version: 1.0.0
Release: 1
-License: ASL
+License: Apache v2.0
Group: Development/Languages/Python
-Source0: http://pypi.python.org/packages/source/m/msgpack-python/msgpack-python-%{version}.tar.gz
-# Source0-md5: cdac1d250cf9c0f0bd36abdfe2c96f8b
+Source0: https://pypi.debian.net/msgpack/%{module}-%{version}.tar.gz
+# Source0-md5: c35ee8f991dad3969884e9585e56ebba
URL: http://msgpack.org/
-BuildRequires: python-devel
+BuildRequires: libstdc++-devel
BuildRequires: rpm-pythonprov
-# if py_postclean is used
-BuildRequires: rpmbuild(macros) >= 1.219
-Requires: python-modules
+BuildRequires: rpmbuild(macros) >= 1.714
+%if %{with python2}
+BuildRequires: python-modules >= 1:2.7
+BuildRequires: python-setuptools
+%endif
+%if %{with python3}
+BuildRequires: python3-devel >= 1:3.5
+BuildRequires: python3-modules
+BuildRequires: python3-setuptools
+%endif
+Requires: python-modules >= 1:2.7
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
JSON. But unlike JSON, it is very fast and small.
%description -l pl.UTF-8
-MessagePack jest binarną, efektywną biblioteką serializacji obiektów.
-Pozwala wymieniać strukturalne obiekty pomiędzy wieloma językami
-podobnie jak JSON. W odróżnieniu jest bardzo szybka i mała.
+MessagePack to biblioteka do binarnej, efektywnej serializacji
+obiektów. Pozwala wymieniać strukturalne obiekty pomiędzy wieloma
+językami, podobnie jak JSON. W odróżnieniu od JSON-a jest bardzo
+szybka i mała.
+
+%package -n python3-%{module}
+Summary: Binary-based efficient data interchange format
+Summary(pl.UTF-8): Binarny, efektywny format wymiany danych
+Group: Libraries/Python
+Requires: python3-modules >= 1:3.5
+
+%description -n python3-%{module}
+MessagePack is a binary-based efficient object serialization library.
+It enables to exchange structured objects between many languages like
+JSON. But unlike JSON, it is very fast and small.
+
+%description -n python3-%{module} -l pl.UTF-8
+MessagePack to biblioteka do binarnej, efektywnej serializacji
+obiektów. Pozwala wymieniać strukturalne obiekty pomiędzy wieloma
+językami, podobnie jak JSON. W odróżnieniu od JSON-a jest bardzo
+szybka i mała.
%prep
-%setup -q -n msgpack-python-%{version}
+%setup -q -n %{module}-%{version}
%build
-CC="%{__cc}" \
-CFLAGS="%{rpmcflags}" \
-%{__python} setup.py build
+%if %{with python2}
+%py_build
+
+%if %{with tests}
+%{__python} -m pytest test
+%endif
+%endif
+
+%if %{with python3}
+%py3_build
+
+%if %{with tests}
+%{__python3} -m pytest test
+%endif
+%endif
%install
rm -rf $RPM_BUILD_ROOT
-%{__python} setup.py install \
- --skip-build \
- --optimize=2 \
- --root=$RPM_BUILD_ROOT
-%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
-%py_comp $RPM_BUILD_ROOT%{py_sitedir}
+%if %{with python2}
+%py_install
+
%py_postclean
+%endif
+
+%if %{with python3}
+%py3_install
+%endif
%clean
rm -rf $RPM_BUILD_ROOT
+%if %{with python2}
%files
%defattr(644,root,root,755)
-%dir %{py_sitedir}/%{module}
-%{py_sitedir}/%{module}/*.py[co]
-%attr(755,root,root) %{py_sitedir}/%{module}/_msgpack.so
-%if "%{py_ver}" > "2.4"
-%{py_sitedir}/%{module}*.egg-info
+%doc COPYING README.md
+%dir %{py_sitescriptdir}/%{module}
+%{py_sitescriptdir}/%{module}/*.py[co]
+%{py_sitescriptdir}/msgpack-%{version}-py*.egg-info
+%endif
+
+%if %{with python3}
+%files -n python3-%{module}
+%defattr(644,root,root,755)
+%doc COPYING README.md
+%dir %{py3_sitedir}/%{module}
+%attr(755,root,root) %{py3_sitedir}/%{module}/_cmsgpack.cpython-*.so
+%{py3_sitedir}/%{module}/*.py
+%{py3_sitedir}/%{module}/__pycache__
+%{py3_sitedir}/msgpack-%{version}-py*.egg-info
%endif