## START: Set by rpmautospec
## (rpmautospec version 0.3.1)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global modname r128gain
%global projname %{modname}

# The tests require network access, so disable them by default
%bcond_with tests

Name:           python-%{projname}
Version:        1.0.6
Release:        %autorelease
Summary:        Fast audio loudness scanner & tagger

License:        LGPL-2.1-only
URL:            https://github.com/desbma/%{projname}
Source0:        %{url}/archive/%{version}/%{projname}-%{version}.tar.gz

BuildArch:      noarch

BuildRequires:  python3-devel

%if %{with tests}
BuildRequires:  python3-requests
BuildRequires:  sox
%endif

%global _description %{expand:
r128gain is a multi platform command line tool to scan your audio files and
tag them with loudness metadata (ReplayGain v2 or Opus R128 gain format), to
allow playback of several tracks or albums at a similar loudness level.
r128gain can also be used as a Python module from other Python projects to
scan and/or tag audio files.}

%description %_description

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

%description -n python3-%{projname} %_description

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

# Remove unwanted shebangs
sed -i /^#!/d r128gain/{__init__,__main__}.py

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files %{modname}

%check
%if %{with tests}
%python3 setup.py test
%else
%pyproject_check_import
%endif

%files -n python3-%{projname} -f %{pyproject_files}
%license LICENSE
%doc README.md
%{_bindir}/%{modname}

%changelog
* Mon Jan 23 2023 John Doe <packager@example.com> - 1.0.6-1
- Uncommitted changes