# SPDX-License-Identifier: MIT
# License text: https://spdx.org/licenses/MIT.html
# Copyright (c) 2023 Maxwell G <gotmax@e.email>
# Copyright (c) Fedora Project Authors

%bcond tests 1

Name:           python-orjson
Version:        3.8.9
Release:        1%{?dist}
Summary:        Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy

License:        Apache-2.0 OR MIT
URL:            https://github.com/ijl/orjson
Source:         %{pypi_source orjson}
Patch:          Use-setuptools-rust-instead-of-maturin.patch
Patch:          Remove-unstable-simd-feature.patch

BuildRequires:  python3-devel
BuildRequires:  rust-packaging


%global _description %{expand:
orjosn is a fast, correct Python JSON library supporting dataclasses,
datetimes, and numpy}


%description %{_description}

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

%description -n python3-orjson %{_description}


%prep
%autosetup -p1 -n orjson-%{version}
%writevars -f pyproject.toml version

%if 0%{?fedora} && 0%{?fedora} <= 36
# Minimal setup.cfg for Fedora 36's old setuptools that doesn't support PEP 621
# (i.e. it doesn't understand metadata in pyproject.toml's [project] table)
cat <<EOF > setup.cfg
[metadata]
name = orjson
version = %{version}

[options]
packages = orjson
EOF
sed -i 's|setuptools>=61.0|setuptools|' pyproject.toml
%endif

%cargo_prep


%generate_buildrequires
%pyproject_buildrequires %{?with_tests:test/requirements.txt}
%cargo_generate_buildrequires


%build
export CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 RUSTFLAGS='%{build_rustflags}'
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files orjson


%check
%pyproject_check_import
%if %{with tests}
%pytest -vv
%endif


%files -n python3-orjson -f %{pyproject_files}
%license LICENSE-MIT LICENSE-APACHE
%doc README.md


%changelog
* Tue Mar 28 2023 Maxwell G <maxwell@gtmx.me> - 3.8.9-1
- Update to 3.8.7.