File wyoming-piper.spec of Package wyoming-piper

#
# spec file for package python-piper
#
# Copyright (c) 2017 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/


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define         pythons %primary_python

%global username piper
%global groupname piper
%global homedir /var/lib/piper

Name:           wyoming-piper
Version:        1.5.0
Release:        0
License:        MIT
Summary:        Text to speech server
Group:          Development/Languages/Python
Url:            https://github.com/rhasspy/wyoming-piper
Source:         wyoming-piper-%{version}.tar.xz
Source2:        wyoming-piper.service
Source3:        wyoming-piper.sysconf
BuildRequires:  %{python_module poetry}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module wheel}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires:       %primary_python-wyoming >= 1.5.3
Requires(pre): shadow
Requires(post): %fillup_prereq
Provides:       group(%{groupname})
Provides:       user(%{username})
Requires:       piper-tts
BuildArch:      noarch

%description
Wyoming Piper speech to text server

%prep
%setup -q -n wyoming-piper-%{version}

%build
%pyproject_wheel

%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}

install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/wyoming-piper.service
install -D -m 0644 %{SOURCE3} %{buildroot}%{_fillupdir}/sysconfig.wyoming-piper
mkdir -p %buildroot%homedir
install -d %{buildroot}%{_localstatedir}/lib/piper

%pre -n wyoming-piper
getent group %{groupname} >/dev/null || groupadd -r %{groupname}
getent passwd %{username} >/dev/null || \
    useradd -r -g %{groupname} -d %{homedir} -s /sbin/nologin \
    -c 'Wyoming Piper User' %{username}
%service_add_pre wyoming-piper.service

%post -n wyoming-piper
%service_add_post wyoming-piper.service
%fillup_only -n wyoming-piper

%postun -n wyoming-piper
%service_del_postun wyoming-piper.service

%files
%license LICENSE.md
%doc CHANGELOG.md README.md
%{_bindir}/wyoming-piper
%{python_sitelib}/*
%{_unitdir}/wyoming-piper.service
%{_fillupdir}/sysconfig.wyoming-piper
%attr(-, piper, piper) %{_localstatedir}/lib/piper

%changelog
openSUSE Build Service is sponsored by