--- /dev/null
+%global srcname pOCCI
+%global commit d61185f1ed58d8bfb8606be256936483d110b78a
+%global shortcommit %(c=%{commit}; echo ${c:0:7})
+
+%{!?py2_build:%global py2_build %{__python2} setup.py build --executable="%{__python2} -s"}
+%{!?py2_install:%global py2_install %{__python2} setup.py install -O1 --skip-build --root %{buildroot}}
+%{!?py3_build:%global py3_build %{__python3} setup.py build --executable="%{__python3} -s"}
+%{!?py3_install:%global py3_install %{__python3} setup.py install -O1 --skip-build --root %{buildroot}}
+
+%if 0%{?rhel}
+%global with_python3 0
+%else
+%global with_python3 1
+%endif
+
+Name: python-%{srcname}
+Version: 0.0.1
+Release: 0.20150826git%{shortcommit}%{?dist}
+Summary: OCCI compliance testing
+
+License: MIT
+URL: https://github.com/CESNET/pOCCI
+Source0: https://github.com/CESNET/%{srcname}/archive/%{commit}/%{srcname}-%{commit}.tar.gz
+# enable 2to3 with workarounds for buggy setuptools
+# (not intended for inclusion in the code)
+Patch1: %{srcname}-2to3.diff
+
+BuildArch: noarch
+BuildRequires: python2-devel python-pycurl
+%if 0%{?with_python3}
+BuildRequires: python3-devel python3-pycurl
+%endif
+BuildRequires: python-sphinx
+
+%description
+OCCI compliance testing.
+
+
+%package -n python2-%{srcname}
+Summary: %{summary}
+BuildArch: noarch
+Requires: python-pycurl
+Requires: python-setuptools
+%{?python_provide:%python_provide python2-%{srcname}}
+
+%description -n python2-pOCCI
+OCCI compliance testing.
+
+%if 0%{?with_python3}
+
+%package -n python3-%{srcname}
+Summary: %{summary}
+Requires: python3-pycurl
+Requires: python3-setuptools
+%{?python_provide:%python_provide python3-%{srcname}}
+
+%description -n python3-%{srcname}
+OCCI compliance testing.
+
+%endif
+
+%package doc
+Summary: Documentation for %{srcname}
+
+%description doc
+User and API documentation for OCCI compliance testing python modules.
+
+
+%prep
+%setup -qc
+pushd %{srcname}-%{commit}
+%patch1 -p1
+# can be removed upstream
+sed -e "/'numpydoc'/d" -i doc/conf.py
+%if 0%{?rhel} && 0%{?rhel} <= 6
+sed -e "/'sphinx.ext.viewcode'/d" -i doc/conf.py
+%endif
+popd
+cp -a %{srcname}-%{commit} python2
+cp -a %{srcname}-%{commit} python3
+
+
+%build
+pushd python2
+%py2_build
+make html
+rm -f build/html/.buildinfo
+popd
+
+%if 0%{?with_python3}
+pushd python3
+%py3_build
+popd
+%endif
+
+
+%install
+pushd python2
+%py2_install
+popd
+cp -p %{buildroot}%{_bindir}/pOCCI %{buildroot}%{_bindir}/pOCCI-2.7
+rm -f %{buildroot}%{python2_sitelib}/%{srcname}/pOCCI.cfg
+rm -rf %{buildroot}%{python2_sitelib}/tests
+chmod +x %{buildroot}%{python2_sitelib}/%{srcname}/pOCCI.py
+
+%if 0%{?with_python3}
+pushd python3
+%py3_install
+cp -p %{buildroot}%{_bindir}/pOCCI %{buildroot}%{_bindir}/pOCCI-3.4
+rm -f %{buildroot}%{python3_sitelib}/%{srcname}/pOCCI.cfg
+rm -rf %{buildroot}%{python3_sitelib}/tests
+chmod +x %{buildroot}%{python3_sitelib}/%{srcname}/pOCCI.py
+rm -f %{buildroot}%{python3_sitelib}/%{srcname}/pOCCI.1
+popd
+%endif
+
+mkdir -p %{buildroot}%{_mandir}/man1
+mv %{buildroot}%{python2_sitelib}/%{srcname}/pOCCI.1 %{buildroot}%{_mandir}/man1/
+rm -f %{buildroot}%{_sysconfdir}/pOCCI.cfg
+
+
+%check
+pushd python2
+%{__python2} setup.py test
+popd
+
+%if 0%{?with_python3}
+# workaround problems with tests in setuptools
+pushd python3/build/lib/tests
+%{__python3} ./test_parse_http.py
+%{__python3} ./test_parse_text.py
+%{__python3} ./test_parse_uri.py
+popd
+%endif
+
+
+%files -n python2-%{srcname}
+%license python2/LICENSE
+%doc python2/README.rst
+%doc python2/%{srcname}/pOCCI.cfg
+%{python2_sitelib}/%{srcname}/
+%{python2_sitelib}/%{srcname}-%{version}*.egg-info/
+%{_bindir}/pOCCI-2*
+%{_mandir}/man1/pOCCI.1*
+%if ! 0%{?with_python3}
+%{_bindir}/pOCCI
+%endif
+
+%if 0%{?with_python3}
+%files -n python3-%{srcname}
+%license python3/LICENSE
+%doc python3/README.rst
+%doc python3/%{srcname}/pOCCI.cfg
+%{python3_sitelib}/%{srcname}/
+%{python3_sitelib}/%{srcname}-%{version}*.egg-info/
+%{_bindir}/pOCCI
+%{_bindir}/pOCCI-3*
+%{_mandir}/man1/pOCCI.1*
+%endif
+
+%files doc
+%doc python2/build/html/
+
+
+%changelog
+* Tue Aug 25 2015 František Dvořák <valtri@civ.zcu.cz> - 0.0.1-0.20150826git72fa242
+- Initial package