Blob Blame History Raw
%if 0%{?fedora} || 0%{?rhel} >= 8
%global with_python3 1
%endif

%global srcname pybtex-docutils

Name:           python-%{srcname}
Version:        0.2.1
Release:        4%{?dist}
Summary:        Docutils backend for pybtex

License:        MIT
URL:            https://github.com/mcmtroffaes/%{srcname}
Source0:        https://files.pythonhosted.org/packages/source/p/%{srcname}/%{srcname}-%{version}.tar.gz
BuildArch:      noarch

BuildRequires:  python2-devel
BuildRequires:  python-docutils
BuildRequires:  python2-nose
BuildRequires:  python2-nose-cov
BuildRequires:  python2-pybtex
BuildRequires:  python2-setuptools
BuildRequires:  python2-six
BuildRequires:  python2-sphinx

%if 0%{?with_python3}
BuildRequires:  python3-devel
BuildRequires:  python3-docutils
BuildRequires:  python3-nose
BuildRequires:  python3-nose-cov
BuildRequires:  python3-pybtex
BuildRequires:  python3-setuptools
BuildRequires:  python3-six
BuildRequires:  python3-sphinx
%endif

%global common_desc \
This package contains a docutils backend for pybtex, a BibTeX-compatible\
bibliography processor written in Python.  Bibliographic references in\
BibTeX format (or any other format supported by pybtex) can be inserted\
into python documentation to be rendered by docutils.

%description
%common_desc

%package -n python2-%{srcname}
Summary:        Docutils backend for pybtex
Requires:       python-docutils
Requires:       python2-pybtex
Requires:       python2-six

Provides:       bundled(jquery)
Provides:       bundled(js-underscore)
%{?python_provide:%python_provide python2-%{srcname}}

%description -n python2-%{srcname}
%common_desc

%if 0%{?with_python3}
%package -n python3-%{srcname}
Summary:        Docutils backend for pybtex
Requires:       python3-docutils
Requires:       python3-pybtex
Requires:       python3-six

Provides:       bundled(jquery)
Provides:       bundled(js-underscore)
%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-%{srcname}
%common_desc
%endif

%prep
%setup -q -c

# Use the new sphinx default theme
sed -i "s/'default'/'alabaster'/" %{srcname}-%{version}/doc/conf.py

# Prepare for python3 build
cp -a %{srcname}-%{version} python3-%{srcname}-%{version}

# Fix doc building with python 3
sed -i 's/"rb"/"rt"/' python3-%{srcname}-%{version}/doc/conf.py

%build
# Python 2 build
pushd %{srcname}-%{version}
%py2_build
PYTHONPATH=$PWD make -C doc html SPHINXBUILD=%{_bindir}/sphinx-build-%{python2_version}
popd

%if 0%{?with_python3}
# Python 3 build
pushd python3-%{srcname}-%{version}
%py3_build
PYTHONPATH=$PWD make -C doc html SPHINXBUILD=%{_bindir}/sphinx-build-%{python3_version}
popd
%endif

%install
# Python 2 install
pushd %{srcname}-%{version}
%py2_install
popd

%if 0%{?with_python3}
# Python 3 install
pushd python3-%{srcname}-%{version}
%py3_install
popd
%endif

%check
# Test the python 2 build
pushd %{srcname}-%{version}
PYTHONPATH=$PWD nosetests-%{python2_version} -v
popd

%if 0%{?with_python3}
# Python 3 install
pushd python3-%{srcname}-%{version}
PYTHONPATH=$PWD nosetests-%{python3_version} -v
popd
%endif

%files -n python2-%{srcname}
%doc %{srcname}-%{version}/doc/_build/html/*
%license %{srcname}-%{version}/LICENSE.rst
%{python2_sitelib}/pybtex_docutils*

%if 0%{?with_python3}
%files -n python3-%{srcname}
%doc python3-%{srcname}-%{version}/doc/_build/html/*
%license python3-%{srcname}-%{version}/LICENSE.rst
%{python3_sitelib}/pybtex_docutils*
%{python3_sitelib}/__pycache__/pybtex_docutils*
%endif

%changelog
* Mon Dec 19 2016 Miro HronĨok <mhroncok@redhat.com> - 0.2.1-4
- Rebuild for Python 3.6

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2.1-3
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Wed Mar  2 2016 Jerry James <loganjerry@gmail.com> - 0.2.1-2
- Expand package description
- Fix sphinx and noseutils invocations for python 3
- Do not convert license file to HTML

* Thu Feb 25 2016 Jerry James <loganjerry@gmail.com> - 0.2.1-1
- Initial RPM