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

%global srcname sphinxcontrib-bibtex

Name:           python-%{srcname}
Version:        0.3.5
Release:        1%{?dist}
Summary:        Sphinx extension for BibTeX style citations

License:        BSD
URL:            https://github.com/mcmtroffaes/sphinxcontrib-bibtex
Source0:        https://github.com/mcmtroffaes/%{srcname}/archive/%{version}.tar.gz
BuildArch:      noarch
# Use orderedset instead of oset; the latter has a dead upstream
Patch0:         %{name}-orderedset.patch

BuildRequires:  python2-coverage
BuildRequires:  python2-devel
BuildRequires:  python2-latexcodec
BuildRequires:  python2-nose
BuildRequires:  python2-orderedset
BuildRequires:  python2-pybtex
BuildRequires:  python2-pybtex-docutils
BuildRequires:  python2-setuptools
BuildRequires:  python2-six
BuildRequires:  python2-sphinx
BuildRequires:  python2-sphinx-testing

%if 0%{?with_python3}
BuildRequires:  python3-coverage
BuildRequires:  python3-devel
BuildRequires:  python3-latexcodec
BuildRequires:  python3-nose
BuildRequires:  python3-orderedset
BuildRequires:  python3-pybtex
BuildRequires:  python3-pybtex-docutils
BuildRequires:  python3-setuptools
BuildRequires:  python3-six
BuildRequires:  python3-sphinx
BuildRequires:  python3-sphinx-testing
%endif

%global common_desc \
This package contains a Sphinx extension for BibTeX style citations.\
\
This extension allows BibTeX citations to be inserted into documentation\
generated by Sphinx, via a bibliography directive, and a cite role,\
which work similarly to LaTeX's thebibliography environment and \\cite\
command.\
\
For formatting, the extension relies on pybtex, written by Andrey\
Golovizin.

%description
%common_desc

%package -n python2-%{srcname}
Summary:        Sphinx extension for BibTeX style citations
Requires:       python2-latexcodec
Requires:       python2-orderedset
Requires:       python2-pybtex
Requires:       python2-pybtex-docutils
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:        Sphinx extension for BibTeX style citations
Requires:       python3-latexcodec
Requires:       python3-orderedset
Requires:       python3-pybtex
Requires:       python3-pybtex-docutils
Requires:       python3-six

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

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

%package doc
Summary:        Documentation for python-%{srcname}

%description doc
Documentation for python-%{srcname}.

%prep
%setup -q -c
pushd %{srcname}-%{version}
%patch0
popd

# Don't run the tinkerer integration test since Fedora doesn't have tinkerer
rm -fr %{srcname}-%{version}/test/{test_issue1.py,issue1}

# Fix a typo in one test
sed -i 's/?}/?/' %{srcname}-%{version}/test/test_latex_refs.py

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

%build
# Python 2 build
pushd %{srcname}-%{version}
%py2_build
popd

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

# Build documentation
%if 0%{?with_python3}
pushd python3-%{srcname}-%{version}
PYTHONPATH=$PWD sphinx-build-%{python3_version} doc html
%else
pushd %{srcname}-%{version}
PYTHONPATH=$PWD sphinx-build-%{python2_version} doc html
%endif
rm -fr html/{.buildinfo,.doctrees}
popd

%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}
# Test the python 3 build
export LANG=en_US.UTF-8
pushd python3-%{srcname}-%{version}
PYTHONPATH=$PWD nosetests-%{python3_version} -v
popd
%endif

%files -n python2-%{srcname}
%license %{srcname}-%{version}/LICENSE.rst
%{python2_sitelib}/sphinxcontrib/
%{python2_sitelib}/sphinxcontrib_bibtex*

%if 0%{?with_python3}
%files -n python3-%{srcname}
%license python3-%{srcname}-%{version}/LICENSE.rst
%{python3_sitelib}/sphinxcontrib/
%{python3_sitelib}/sphinxcontrib_bibtex*
%endif

%files doc
%if 0%{?with_python3}
%doc python3-%{srcname}-%{version}/html/*
%else
%doc %{srcname}-%{version}/html/*
%endif

%changelog
* Wed Feb 22 2017 Jerry James <loganjerry@gmail.com> - 0.3.5-1
- New upstream version

* Mon May 23 2016 Jerry James <loganjerry@gmail.com> - 0.3.4-1
- New upstream version

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