Blob Blame History Raw
%global pypi_name sphinx-intl
%global srcname sphinx_intl
%global cmdname sphinx-intl
%global project_owner sphinx-doc
%global github_name sphinx-intl
%global commit bf6edc2e505567768eb230099c9960ccdedd12b5
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global desc sphinx-intl is a utility tool that provides several features that make it easy \
to translate and to apply translation to Sphinx generated document. Optional: \
support the Transifex service for translation with Sphinx (not packaged yet).

# Match what is done in python-sphinx
%global py2_alt_priority 100
%if 0%{?fedora} > 24
%global py3_alt_priority 500
%else
%global py3_alt_priority 10
%endif


Name:           python-%{pypi_name}
Version:        0.9.9
Release:        3.git%{shortcommit}%{?dist}
Summary:        Sphinx utility that make it easy to translate and to apply translation

License:        BSD
URL:            https://pypi.python.org/pypi/%{pypi_name}
Source0:        https://github.com/%{project_owner}/%{github_name}/archive/%{commit}/%{github_name}-%{commit}.tar.gz

BuildArch:      noarch

%description
%desc


%package -n python2-%{pypi_name}
Summary:        %{summary}
BuildRequires:  python2-devel
BuildRequires:  python2-setuptools
BuildRequires:  python2-pytest
BuildRequires:  python2-six
BuildRequires:  python-click
BuildRequires:  python2-babel
BuildRequires:  python2-sphinx
Requires(post): %{_sbindir}/update-alternatives
Requires(postun): %{_sbindir}/update-alternatives
Requires:       python2-setuptools
Requires:       python2-six
Requires:       python-click
Requires:       python2-babel
Requires:       python2-sphinx
%{?python_provide:%python_provide python2-%{pypi_name}}

%description -n python2-%{pypi_name}
%desc


%package -n     python%{python3_pkgversion}-%{pypi_name}
Summary:        %{summary}
BuildArch:      noarch
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-setuptools
BuildRequires:  python%{python3_pkgversion}-pytest
BuildRequires:  python%{python3_pkgversion}-six
BuildRequires:  python%{python3_pkgversion}-click
BuildRequires:  python%{python3_pkgversion}-babel
BuildRequires:  python%{python3_pkgversion}-sphinx
Requires(post): %{_sbindir}/update-alternatives
Requires(postun): %{_sbindir}/update-alternatives
Requires:       python%{python3_pkgversion}-setuptools
Requires:       python%{python3_pkgversion}-six
Requires:       python%{python3_pkgversion}-click
Requires:       python%{python3_pkgversion}-babel
Requires:       python%{python3_pkgversion}-sphinx
%{?python_provide:%python_provide python%{python3_pkgversion}-%{pypi_name}}

%description -n python%{python3_pkgversion}-%{pypi_name}
%desc


%prep
%setup -qn %{github_name}-%{commit}
# Correct line encoding in README.rst
sed -i 's/\r$//' README.rst


%build
%py2_build
%py3_build


%install
%py2_install
pushd %{buildroot}%{_bindir}
mv %{cmdname} %{cmdname}-%{python2_version}
ln -s %{cmdname}-%{python2_version} %{cmdname}-2
popd

%py3_install
pushd %{buildroot}%{_bindir}
mv %{cmdname} %{cmdname}-%{python3_version}
ln -s %{cmdname}-%{python3_version} %{cmdname}-3
popd

touch %{buildroot}%{_bindir}/%{cmdname}


%check
# Transifex is not packaged. Remove tests that depens on it.
rm tests/test_*transifex*.py
export LC_ALL=en_US.utf-8
PYTHONPATH="$(pwd)" py.test-%{python2_version} -v .
PYTHONPATH="$(pwd)" py.test-%{python3_version} -v .


%post -n python2-%{pypi_name}
update-alternatives --install %{_bindir}/%{cmdname} %{cmdname} %{_bindir}/%{cmdname}-%{python2_version} %{py2_alt_priority}


%post -n python3-%{pypi_name}
update-alternatives --install %{_bindir}/%{cmdname} %{cmdname} %{_bindir}/%{cmdname}-%{python3_version} %{py3_alt_priority}


%postun -n python2-%{pypi_name}
if [ $1 -eq 0 ] ; then
  update-alternatives --remove %{cmdname} %{_bindir}/%{cmdname}-%{python2_version}
fi


%postun -n python3-%{pypi_name}
if [ $1 -eq 0 ] ; then
  update-alternatives --remove %{cmdname} %{_bindir}/%{cmdname}-%{python3_version}
fi


%files -n python2-%{pypi_name}
%license LICENSE
%doc README.rst
%ghost %{_bindir}/%{cmdname}
%{python2_sitelib}/%{srcname}-%{version}*-py%{python2_version}.egg-info/
%{python2_sitelib}/%{srcname}/
%{_bindir}/%{cmdname}-2*


%files -n python%{python3_pkgversion}-%{pypi_name}
%license LICENSE
%doc README.rst
%ghost %{_bindir}/%{cmdname}
%{python3_sitelib}/%{srcname}-%{version}*-py%{python3_version}.egg-info/
%{python3_sitelib}/%{srcname}/
%{_bindir}/%{cmdname}-3*


%changelog
* Sun Oct 09 2016 Julien Enselme <jujens@jujens.eu> - 0.9.9-3.gitbf6edc2
- Remove duplicated pattern in %%files

* Wed Oct 05 2016 Julien Enselme <jujens@jujens.eu> - 0.9.9-2.gitbf6edc2
- Add LC_ALL for tests to pass in build env

* Wed Sep 14 2016 Julien Enselme <jujens@jujens.eu> - 0.9.9-1.gitbf6edc2
- Initial packaging