## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 4;
    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 forgeurl https://github.com/tweag/FawltyDeps

%bcond tests 1

Name:           fawltydeps
Version:        0.17.0
Release:        %{autorelease}
Summary:        Find undeclared and unused 3rd-party dependencies in your Python project
%forgemeta
License:        MIT
URL:            %forgeurl
Source:         %forgesource

BuildArch:      noarch
BuildRequires:  python3-devel
# For generating man pages
BuildRequires:  help2man
%if %{with tests}
BuildRequires:  python3-pytest
BuildRequires:  python3-hypothesis
%endif

%global _description %{expand:
FawltyDeps is a dependency checker for Python that finds undeclared
and/or unused 3rd-party dependencies in your Python project. The name
is inspired by the Monty Python-adjacent Fawlty Towers sitcom.}

%description %_description


# TODO: Enable `uv` extra sub package once available
# https://bugzilla.redhat.com/show_bug.cgi?id=2299712
#%%pyproject_extras_subpkg -n python3-{name} uv


%prep
%forgeautosetup -p1
# Drop version pinning on `packaging` for F41-
%if %{fedora} < 41
sed -r \
    -e 's/(packaging) =.*/\1 = "*"/' \
    -i pyproject.toml
%endif


%generate_buildrequires
# TODO: Add `-x uv` once `uv` is available
# https://bugzilla.redhat.com/show_bug.cgi?id=2299712
%pyproject_buildrequires


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files %{name}

# Create man pages from --help and --version
mkdir man
%{py3_test_envvars} help2man --section 1 --no-discard-stderr \
--no-info --output man/%{name}.1 %{name}
mkdir -p %{buildroot}%{_mandir}/man1
install -m 0644 man/%{name}.1 %{buildroot}%{_mandir}/man1


%check
%if %{with tests}
# Disable tests requiring network
k="${k-}${k+ and }not test_resolve_dependencies_install_deps"
k="${k-}${k+ and }not generates_expected_mappings"
# TypeError: 'NoneType' object is not subscriptable
k="${k-}${k+ and }not no_pyenvs_found"
%pytest -v "${k:+-k $k}"
%else
%pyproject_check_import
%endif


%files -f %{pyproject_files}
%doc README.*
%license LICENSE
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1*


%changelog
## START: Generated by rpmautospec
* Wed Jul 24 2024 Packit <hello@packit.dev> - 0.17.0-1
- Update to 0.17.0 upstream release
- Resolves: rhbz#2299646

* Wed Jul 17 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Tue Jun 18 2024 Packit <hello@packit.dev> - 0.16.0-1
- Update to 0.16.0 upstream release
- Resolves: rhbz#2292905

* Wed Mar 13 2024 Sandro <devel@penguinpee.nl> - 0.15.0-4
- Fix Packit config

* Sun Jan 28 2024 Sandro <devel@penguinpee.nl> - 0.15.0-3
- Relax version constraints on dependencies

* Fri Jan 26 2024 Sandro <devel@penguinpee.nl> - 0.15.0-2
- Add Packit config

* Fri Jan 26 2024 Sandro <devel@penguinpee.nl> - 0.15.0-1
- Update to 0.15.0 (RHBZ#2259245)

* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Tue Jan 16 2024 Sandro <devel@penguinpee.nl> - 0.13.3-1
- New package (RHBZ#2251482)
- Find undeclared and unused 3rd-party dependencies in your Python project
## END: Generated by rpmautospec