%{?!python3_pkgversion:%global python3_pkgversion 3}
%global debug_package %{nil}
%global srcname PyHT6022
%global plainname hantek6022api

Name:           Hantek6022API
Version:        2.10.4
Release:        1%{?dist}
Summary:        Hantek 6022BE Python API for Windows and Linux.
License:        GPLv2
URL:            https://github.com/Ho-Ro/Hantek6022API
Source0:        https://github.com/Ho-Ro/Hantek6022API/archive/refs/tags/%{version}.tar.gz

BuildArch:      x86_64

BuildRequires:  make gcc gcc-c++ sdcc pkgconfig(libusb-1.0)
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-pip
BuildRequires:  python%{python3_pkgversion}-wheel
BuildRequires:  python%{python3_pkgversion}-setuptools

# For the %%_udevrulesdir macro
BuildRequires:  systemd
# For the directory
Requires:       systemd-udev

%{?python_enable_dependency_generator}

%description
This is a API for Python for the ultra-cheap, reasonably usable (and hackable) 6022 DSO, with a libusb implementation via libusb1 for Linux.


%package -n python%{python3_pkgversion}-%{srcname}
Summary:        %{summary}
%{?python_provide:%python_provide python3-%{srcname}}

%if %{undefined python_enable_dependency_generator} && %{undefined python_disable_dependency_generator}
# Put manual requires here:
Requires:       python%{python3_pkgversion}-foo
%endif

%description -n python%{python3_pkgversion}-%{srcname}
...


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


%build
%make_build CFLAGS="%{build_cflags}" CXXFLAGS="%{build_cxxflags}" LDFLAGS="%{build_ldflags}" -C fx2upload
%py3_build


%install
rm -rf %{buildroot}
%py3_install
%{__install} -d %{buildroot}%{_udevrulesdir}
%{__install} -D -m0644 udev/60-hantek6022api.rules %{buildroot}%{_udevrulesdir}
rm -rf %{buildroot}%{_sysconfdir}

%post
%udev_rules_update

%postun
%udev_rules_update

%files -n  python%{python3_pkgversion}-%{srcname}
%license LICENSE
%doc README.md
# For noarch packages: sitelib
%{python3_sitelib}/%{srcname}/
# For arch-specific packages: sitearch
%{python3_sitelib}/%{plainname}-%{version}-py%{python3_version}.egg-info/
%{_udevrulesdir}/60-hantek6022api.rules
%{_bindir}/calibrate_6022.py
%{_bindir}/capture_6022.py
%{_bindir}/fft_from_capture_6022.py
%{_bindir}/fft_ft_from_capture_6022.py
%{_bindir}/fx2upload
%{_bindir}/plot_from_capture_6022.py
%{_bindir}/set_cal_out_freq_6022.py
%{_bindir}/upload_6022_firmware.py
%{_bindir}/upload_6022_firmware_from_hex.py
%{_docdir}/%{plainname}

%changelog
* Mon Sep 05 2022 Thomas Büttner <thomas@vergesslicher.tech>
-