## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 2;
    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

Name:           python-mapbox-earcut
Version:        1.0.2
Release:        %autorelease
Summary:        Python bindings to the mapbox earcut C++ library

# The entire source is (SPDX) ISC; the License also includes the licenses of
# two header-only libraries that are compiled into the extension:
#   - earcut-hpp-static is also ISC
#   - pybind11-static is BSD-3-Clause
License:        ISC AND BSD-3-Clause
SourceLicense:  ISC
URL:            https://github.com/skogler/mapbox_earcut_python
# The GitHub archive contains tests; the PyPI archive does not
Source:         %{url}/archive/v%{version}/mapbox_earcut_python-%{version}.tar.gz

BuildRequires:  python3-devel

BuildRequires:  gcc-c++
BuildRequires:  cmake
BuildRequires:  make

# Header-only libraries; -static is for tracking, required by guidelines
# Minimum version added downstream to ensure the latest bug fixes are present.
# Note that upstream of this package bundles earcut.hpp 2.2.4 in release 1.0.1.
BuildRequires:  earcut-hpp-devel >= 2.2.4
BuildRequires:  earcut-hpp-static
# An extension built with pybind11 uses the pybind11 C++ libraries, which are
# header-only—so, strictly speaking, we need this as well:
BuildRequires:  pybind11-static

BuildRequires:  dos2unix

%global common_description %{expand:
Python bindings for the C++ implementation of the Mapbox Earcut library, which
provides very fast and quite robust triangulation of 2D polygons.

Original code: earcut.hpp

Original description:

    The library implements a modified ear slicing algorithm, optimized by
    z-order curve hashing and extended to handle holes, twisted polygons,
    degeneracies and self-intersections in a way that doesn’t guarantee
    correctness of triangulation, but attempts to always produce acceptable
    results for practical data like geographical shapes.}

%description %{common_description}


%package -n python3-mapbox-earcut
Summary:        %{summary}

%description -n python3-mapbox-earcut %{common_description}


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

# Remove bundled earcut.hpp library
rm -rvf include

# Fix CRLF line endings in files that will be installed.
dos2unix --keepdate *.md


%generate_buildrequires
%pyproject_buildrequires -x test


%build
# See comments in the earcut-hpp spec file, as well as:
# https://github.com/mapbox/earcut.hpp/issues/97
# https://github.com/mapbox/earcut.hpp/issues/103
export CFLAGS="${CFLAGS-} -ffp-contract=off"
export CXXFLAGS="${CXXFLAGS-} -ffp-contract=off"

%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files -l mapbox_earcut


%check
%pytest


%files -n python3-mapbox-earcut -f %{pyproject_files}
%doc README.md


%changelog
## START: Generated by rpmautospec
* Sat Dec 14 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.2-2
- Add a SourceLicense field

* Mon Aug 05 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.2-1
- Update to 1.0.2 (close RHBZ#2302636)

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Sat Jun 08 2024 Python Maint <python-maint@redhat.com> - 1.0.1-14
- Rebuilt for Python 3.13

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Dec 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.1-10
- Assert that %%pyproject_files contains a license file

* Fri Oct 13 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.1-9
- Remove an obsolete (pre-F36) conditional workaround

* Wed Sep 27 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.1-8
- Keep timestamps when converting text file line endings

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Tue Jun 13 2023 Python Maint <python-maint@redhat.com> - 1.0.1-6
- Rebuilt for Python 3.12

* Sat Jun 03 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.1-5
- Remove explicit %%set_build_flags, not needed since F36

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Tue Jan 10 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.1-2
- Update License to include header-only dependencies

* Sat Dec 03 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.1-1
- Update to 1.0.1 (close RHBZ#2150381)

* Thu Sep 08 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.0-6
- Rebuild with earcut-hpp 2.2.4

* Thu Sep 08 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.0-5
- Build with -ffp-contract=off
- For the underlying C++ library, this fixes certain test failures on
  aarch64, ppc64le, and s390x. The tests for this package are less “picky”
  and pass either way.

* Thu Sep 08 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.0-4
- Note that License is *SPDX* ISC

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 1.0.0-2
- Rebuilt for Python 3.11

* Wed Feb 02 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.0-1
- Initial package (close RHBZ#2018705)
## END: Generated by rpmautospec