File python3-subliminal.spec of Package python3-subliminal

#
# spec file for package python3-subliminal
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%define         subliminal_priority 30

Name:           python3-subliminal
Version:        2.0.5
Release:        0
Summary:        Python library to search and download subtitles
License:        MIT
Group:          Development/Languages/Python
Url:            https://github.com/Diaoul/subliminal
Source0:        https://github.com/Diaoul/subliminal/archive/%{version}.tar.gz#/subliminal-%{version}.tar.gz
Source1:        subliminal.1
BuildRequires:  fdupes
BuildRequires:  python3-appdirs >= 1.3
BuildRequires:  python3-babelfish >= 0.5.4
BuildRequires:  python3-beautifulsoup4 >= 4.4.0
BuildRequires:  python3-chardet >= 2.3.0
BuildRequires:  python3-click >= 4.1
BuildRequires:  python3-devel
BuildRequires:  python3-dogpile.cache >= 0.6.0
BuildRequires:  python3-enzyme >= 0.4.1
BuildRequires:  python3-pysrt >= 1.0.1
BuildRequires:  python3-rarfile >= 2.7
BuildRequires:  python3-requests >= 2.7.0
BuildRequires:  python3-setuptools >= 18.0.1
BuildRequires:  python3-six >= 1.9.0
BuildRequires:  python3-stevedore >= 1.6.0
BuildRequires:  python3-xdg >= 0.25
Requires:       python3-appdirs >= 1.3
Requires:       python3-babelfish >= 0.5.4
Requires:       python3-beautifulsoup4 >= 4.4.0
Requires:       python3-chardet >= 2.3.0
Requires:       python3-click >= 4.1
Requires:       python3-dbm
Requires:       python3-dogpile.cache >= 0.6.0
Requires:       python3-enzyme >= 0.4.1
Requires:       python3-guessit >= 2.0.1
Requires:       python3-pysrt >= 1.0.1
Requires:       python3-pytz >= 2012c
Requires:       python3-rarfile >= 2.7
Requires:       python3-requests >= 2.7.0
Requires:       python3-six >= 1.9.0
Requires:       python3-stevedore >= 1.6.0
Requires:       python3-xdg >= 0.25
Requires(post): update-alternatives
Requires(postun): update-alternatives
Recommends:     python3-colorlog >= 2.6.0
BuildArch:      noarch

%description
Subliminal is a python library to search and download subtitles.
It comes with a CLI suitable for direct use or cron jobs.

%prep
%setup -q -n subliminal-%{version}
# set the exe name
sed -e 's/subliminal = subliminal.cli:subliminal/subliminal-%{py3_ver} = subliminal.cli:subliminal/' -i setup.py
gzip < %{SOURCE1} > subliminal-%{py3_ver}.1.gz

%build
python3 setup.py build

%install
python3 setup.py install --skip-build --prefix=%{_prefix} --root=%{buildroot}
mkdir -p %{buildroot}/%{_docdir}/%{name} \
         %{buildroot}%{_mandir}/man1
install -m 0644 subliminal-%{py3_ver}.1.gz %{buildroot}%{_mandir}/man1
# Setup update-alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/subliminal
touch %{buildroot}%{_sysconfdir}/alternatives/subliminal.1.gz
ln -s -f %{_sysconfdir}/alternatives/subliminal %{buildroot}%{_bindir}/subliminal
ln -s -f %{_sysconfdir}/alternatives/subliminal.1.gz %{buildroot}%{_mandir}/man1/subliminal.1.gz
%fdupes -s %{buildroot}

%post
update-alternatives \
  --install %{_bindir}/subliminal                    subliminal               %{_bindir}/subliminal-%{py3_ver} \
            %{subliminal_priority} \
  --slave   %{_mandir}/man1/subliminal.1.gz          subliminal.1.gz          %{_mandir}/man1/subliminal-%{py3_ver}.1.gz

%postun
# Note: we don't use "$1 -eq 0", to avoid issues if the package gets renamed
if [ ! -f %{_bindir}/subliminal-%{py3_ver} ]; then
  update-alternatives --remove subliminal %{_bindir}/subliminal-%{py3_ver}
fi

%files
%defattr(-,root,root)
%doc HISTORY.rst LICENSE README.rst
%{_bindir}/subliminal
%{_bindir}/subliminal-%{py3_ver}
%ghost %{_sysconfdir}/alternatives/subliminal
%{_mandir}/man1/subliminal.1.gz
%{_mandir}/man1/subliminal-%{py3_ver}.1.gz
%ghost %{_sysconfdir}/alternatives/subliminal.1.gz
%dir %{python3_sitelib}/subliminal
%{python3_sitelib}/subliminal/*
%{python3_sitelib}/subliminal-%{version}-py%{py3_ver}.egg-info

%changelog
openSUSE Build Service is sponsored by