## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## 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 srcname jiter
%global _description %{summary}.

Name:           python-%{srcname}
Version:        0.7.1
Release:        %autorelease
Summary:        Fast iterable JSON parser

# python-jiter is MIT only, but the rest are rust libraries
# based on cargo_license_summary output:
#
# Apache-2.0 OR MIT
# BSD-2-Clause OR Apache-2.0 OR MIT
# MIT
# MIT OR Apache-2.0 (duplicate)
License:        %{shrink:
                (Apache-2.0 OR MIT) AND
                (BSD-2-Clause OR Apache-2.0 OR MIT) AND
                MIT
                }
URL:            https://github.com/pydantic/jiter/
Source:         %{pypi_source %{srcname}}

BuildRequires:  python3-devel
BuildRequires:  tomcli

# For included rust code
BuildRequires:  cargo-rpm-macros

# For tests
BuildRequires:  python3dist(dirty-equals)
BuildRequires:  python3dist(pytest)

%description
%{_description}

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

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


%prep
%autosetup -p1 -n %{srcname}-%{version}
# There is no top-level LICENSE file, but the one from the bundled jiter crate
# is the correct license.
mv crates/jiter/LICENSE ./

# However, we want to use the system copy of the jiter crate.
rm -r crates/jiter

# E.g., for 0.5.0, this would allow 0.5.x.
tomcli set crates/jiter-python/Cargo.toml str dependencies.jiter.version "%{version}"
tomcli set crates/jiter-python/Cargo.toml del dependencies.jiter.path

# This feature only applies to Windows, and is hidden in our PyO3 packages.
# We can and should remove it with no consequence.
tomcli set pyproject.toml lists delitem \
    tool.maturin.features pyo3/generate-import-lib
tomcli set crates/jiter-python/Cargo.toml lists delitem \
    features.extension-module pyo3/generate-import-lib

%cargo_prep


%generate_buildrequires
%cargo_generate_buildrequires -a
%pyproject_buildrequires


%build
%pyproject_wheel

%cargo_license_summary
%{cargo_license} > LICENSE.dependencies


%install
%pyproject_install
%pyproject_save_files %{srcname}


%check
%pyproject_check_import
%pytest


%files -n python3-%{srcname} -f %{pyproject_files}
%license LICENSE LICENSE.dependencies
%doc README.md


%changelog
## START: Generated by rpmautospec
* Sat Nov 16 2024 Packit <hello@packit.dev> - 0.7.1-1
- Update to 0.7.1 upstream release
- Resolves: rhbz#2317026

* Wed Oct 16 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.5.0-3
- Drop SONAME workaround; the fix is present in rust-1.81.0-4 and later

* Mon Sep 30 2024 Major Hayden <major@redhat.com> - 0.5.0-2
- Add packit config

* Mon Sep 30 2024 Major Hayden <major@redhat.com> - 0.5.0-1
- First package rhbz#2313784
## END: Generated by rpmautospec