File python-hidapi.spec of Package python-hidapi

%global pypi_name hidapi
%global py_setup_args --with-system-hidapi --with-libusb

Name:     python-%{pypi_name}
Version:  0.14.0.post4
Release:  2%{?dist}
Summary:  Interface to the %{pypi_name} library

# Automatically converted from old format: GPLv3+ or BSD or Public Domain - review is highly recommended.
License:  GPL-3.0-or-later OR LicenseRef-Callaway-BSD OR LicenseRef-Callaway-Public-Domain
URL:      https://github.com/trezor/cython-hidapi
Source0:  https://files.pythonhosted.org/packages/source/h/%{pypi_name}/%{pypi_name}-%{version}.tar.gz

BuildRequires:  gcc
BuildRequires:  hidapi-devel
BuildRequires:  libusbx-devel
BuildRequires:  libudev-devel

BuildRequires:  python3-devel
BuildRequires:  python3-pytest
BuildRequires:  python3-setuptools
BuildRequires:  python3-cython

%description
%{summary}.


%package -n python3-%{pypi_name}
Summary:  %{summary}

%description -n python3-%{pypi_name}
%{summary}.


%prep
%autosetup -n %{pypi_name}-%{version}

# Remove pre-built and bundled hidapi.
rm -rf hidapi %{pypi_name}.egg-info hid.c

%if 0%{?flatpak}
# hidapi is not part of the runtime and is also built into /app
sed -i -e 's|/usr/include/hidapi|%{_includedir}/hidapi|' setup.py
%endif

%build
%py3_build


%install
%py3_install


%check
%{pytest} tests.py


%files -n python3-%{pypi_name}
%license LICENSE*.txt
%doc README.rst try.py
%{python3_sitearch}/hid%{python3_ext_suffix}
%{python3_sitearch}/hidraw%{python3_ext_suffix}
%{python3_sitearch}/%{pypi_name}-%{version}-py%{python3_version}.egg-info