File music-assistant.spec of Package music-assistant

#
# spec file for package music-assistant
#
# 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-%{**} python311-%{**}}
# must be a single on or the rest of spec file won't work
%define pythons python312
# last time we used this, so try to pull in all the optional modules
%define oldpythons python311

%bcond_with     test

Name:           music-assistant
Version:        2.3.2
Release:        0
Summary:        Music Assistant Server for Home Assistant
License:        Apache-2.0
Group:          Development/Languages/Python
Url:            https://music-assistant.io/
Source:         server-%{version}.tar.xz
Source1:        music-assistant.service
Source2:        music-assistant-stream.xml
Source3:        music-assistant-web.xml
# No reason to conflict with home-assistant versions
Patch1:         versions.patch

BuildRequires:  %{python_module aiohttp}
BuildRequires:  %{python_module astral}
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module jaraco.functools}
BuildRequires:  %{python_module Jinja2}
BuildRequires:  %{python_module MarkupSafe}
BuildRequires:  %{python_module PyYAML}
BuildRequires:  %{python_module pytz}
BuildRequires:  %{python_module requests}
BuildRequires:  %{python_module poetry-core}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module typing}
BuildRequires:  %{python_module virtualenv}
BuildRequires:  %{python_module voluptuous}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module wheel}
BuildRequires:  %{python_module PyDispatcher}

BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  %pythons
Requires:  %pythons
# for useradd call
Requires(pre): shadow

# for spotify:
Recommends: /usr/bin/librespot

Recommends: python-aiosonos
Recommends: python-aiomusiccast

BuildArch:     noarch

Requires: %pythons-deprecation
Requires: %pythons-filetype
Requires: ffmpeg >= 6

# hard base requirements
Requires: %pythons-Brotli
Requires: %pythons-aiodns
Requires: %pythons-aiofiles
Requires: %pythons-aiohttp
Requires: %pythons-aiorun
Requires: %pythons-aiosqlite
Requires: %pythons-async-upnp-client
Requires: %pythons-chardet
Requires: %pythons-mutagen
Requires: %pythons-faust-cchardet
Requires: %pythons-hass-client
Requires: %pythons-ifaddr
Requires: %pythons-memory-tempfile
Requires: %pythons-music-assistant-frontend
Requires: %pythons-music-assistant-models
Requires: %pythons-orjson
Requires: %pythons-PyChromecast
Requires: %pythons-python-slugify
Requires: %pythons-radios
Requires: %pythons-shortuuid
Requires: %pythons-unidecode
Requires: %pythons-zeroconf

Requires: %pythons-duration-parser >= 1.0.1

Requires: %pythons-aiohttp >= 3.10.0
Requires: %pythons-certifi >= 2024.8.30
Requires: %pythons-colorlog >= 6.8.2
Requires: %pythons-cryptography >= 43.0.1
Requires: %pythons-mashumaro >= 1.13.1
Requires: %pythons-pillow >= 11.0.0
Requires: %pythons-xmltodict >= 0.13.0
Requires: %pythons-zeroconf >= 0.136.2

Requires: (%pythons-PyChromecast >= 14.0.5 if (%oldpythons-PyChromecast or %pythons-PyChromecast))
Requires: (%pythons-yt-dlp >= 2024.10.7 if (%oldpythons-yt-dlp or %pythons-yt-dlp))

# tracking versions at least as minimum
%( tar xf %{S:0} --wildcards \*/requirements_all.txt --to-command='grep -v ^# | grep -v ^$ | grep -v ^- | grep -v ";python_version<.3.11." | sed -e /^aiohttp/d -e /^certifi/d -e /^colorlog/d -e /^cryptography/d -e /^mashumaro/d -e /^xmltodict/d -e /^PyChromecast/d -e /^yt-dlp/d -e /^pillow/d -e /^zeroconf/d | sed -e 's,=v,=,' -e "s,\[[^\]*],," -e "s,\(.*\)\(.=\)\(.*\),Requires: (%pythons-\1 \2 \3 if (%oldpythons-\1 or %pythons-\1)),"' )

%systemd_requires

%description
The Music Assistant Server. For collecting all your local or remote music and offering it
via a unique interface. Intended to be used with home assistant, but works also stand alone.

%prep
%autosetup -p1 -n server-%{version}
# drop pre-compiled binaries
rm -r music_assistant/providers/*/bin

%build
%pyproject_wheel

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

mkdir -p '%{buildroot}'%{_sbindir}
ln -sf service '%{buildroot}'%{_sbindir}/rcmusic-assistant
install -D -m 644 %{_sourcedir}/music-assistant.service '%{buildroot}'%{_unitdir}/music-assistant.service
# Create mass alias name
ln -s music-assistant.service '%{buildroot}'%{_unitdir}/mass.service

mkdir -p %{buildroot}/%{_prefix}/lib/firewalld/services/
install -D -m 644 %{SOURCE2} %{buildroot}/%{_prefix}/lib/firewalld/services/
install -D -m 644 %{SOURCE3} %{buildroot}/%{_prefix}/lib/firewalld/services/

%if %{with test}
%check
%python_exec -m pytest tests -k "not (TestTimeout and connect)"
%endif

%pre -n music-assistant
getent passwd mass >/dev/null || \
    /usr/sbin/useradd -r -m -s %{_sbindir}/nologin \
    -c "Home Assitant User" mass
%service_add_pre music-assistant.service
exit 0

%preun -n music-assistant
%service_del_preun music-assistant.service

%post -n music-assistant
%service_add_post music-assistant.service

%postun -n music-assistant
%service_del_postun music-assistant.service

%files
%doc README.md
%license LICENSE
%_unitdir/mass.service
%_unitdir/music-assistant.service
%_bindir/mass
%_sbindir/rcmusic-assistant
%{python_sitelib}/*
%dir %{_prefix}/lib/firewalld
%dir %{_prefix}/lib/firewalld/services
%{_prefix}/lib/firewalld/services/music-assistant-*.xml

%changelog
openSUSE Build Service is sponsored by