File python-hhd.spec of Package hhd

#
# spec file for package hhd
#
# Copyright (c) 2025 SUSE LLC and contributors
#
# 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 https://bugs.opensuse.org/
#


Name:           python-hhd
Version:        4.1.5
Release:        0
Summary:        A tool for configuring handheld devices
License:        LGPL-2.1-or-later
URL:            https://github.com/hhd-dev/hhd
Source:         https://github.com/hhd-dev/hhd/archive/refs/tags/v%{version}.tar.gz
Patch:          hhd-fix-scripts.patch
Provides:       hhd
Requires:       hhd-common
BuildArch:      noarch

BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module wheel}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module Babel}

Requires:       python3
Requires:       python-evdev
Requires:       python-rich
Requires:       python-dbus-python
Requires:       python-PyYAML
Requires:       python-setuptools
Requires:       python-xlib
Requires:       python-pyserial
Requires:       python-pyroute2
Requires:       python-gobject
Requires(post): update-alternatives
Requires(postun): update-alternatives
%python_subpackages

%description
Handheld Daemon contains utilities for managing handheld devices.
Features include TDP controls, controller remappings, and gamescope
session management. This is done through a plugin system and a
HTTP/D-Bus daemon, which exposes the settings of the plugins in a
UI-agnostic way.

%package -n hhd-common
Summary:        Files shared between python hhd pacakges
BuildRequires:  systemd-rpm-macros
BuildRequires:  udev
Requires:       udev

%description -n hhd-common
This package contains the files shared between the python hhd pacakges.

%prep
%autosetup -p1 -n hhd-%{version}

%build
python3 -m babel.messages.frontend compile -D hhd -d ./i18n
python3 -m babel.messages.frontend compile -D adjustor -d ./i18n || true
cp -rf ./i18n/* ./src/hhd/i18n

%pyproject_wheel

%install
%pyproject_install

%python_expand chmod 0755 %{buildroot}%{$python_sitelib}/adjustor/drivers/gpu/ppd.py

find %{buildroot} -name '*.pyc' -delete
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%python_clone -a %{buildroot}%{_bindir}/hhd
%python_clone -a %{buildroot}%{_bindir}/hhd.contrib
%python_clone -a %{buildroot}%{_bindir}/hhd.steamos
%python_clone -a %{buildroot}%{_bindir}/hhdctl

mkdir -p %{buildroot}%{_udevrulesdir}
install -m644 usr/lib/udev/rules.d/83-hhd.rules %{buildroot}%{_udevrulesdir}/83-hhd.rules
mkdir -p %{buildroot}%{_udevhwdbdir}
install -m644 usr/lib/udev/hwdb.d/83-hhd.hwdb %{buildroot}%{_udevhwdbdir}/83-hhd.hwdb
mkdir -p %{buildroot}%{_unitdir}
install -m644 usr/lib/systemd/system/hhd@.service %{buildroot}%{_unitdir}/hhd@.service
install -m644 usr/lib/systemd/system/hhd.service %{buildroot}%{_unitdir}/hhd.service

%post
%python_install_alternative hhd hhd.contrib hhd.steamos hhdctl

%postun
%python_uninstall_alternative hhd hhd.contrib hhd.steamos hhdctl

%pre -n hhd-common
%service_add_pre hhd.service

%post -n hhd-common
%service_add_post hhd.service

%preun -n hhd-common
%service_del_preun hhd.service

%postun -n hhd-common
%service_del_postun hhd.service

%files -n hhd-common
%license LICENSE
%doc readme.md
%{_udevrulesdir}/83-hhd.rules
%{_udevhwdbdir}/83-hhd.hwdb
%{_unitdir}/hhd@.service
%{_unitdir}/hhd.service

%files %{python_files}
%{python_sitelib}/hhd*
%python_alternative hhd
%python_alternative hhd.contrib
%python_alternative hhd.steamos
%python_alternative hhdctl

%{python_sitelib}/adjustor*

%changelog
openSUSE Build Service is sponsored by