## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## 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 cartopy

# Some tests use the network.
%bcond_with network

Name:           python-%{srcname}
Version:        0.24.1
Release:        %autorelease
Summary:        Cartographic Python library with Matplotlib visualisations

License:        BSD-3-Clause
URL:            https://scitools.org.uk/cartopy/docs/latest/
Source0:        %pypi_source %{srcname}
# Set location of Fedora-provided pre-existing data.
Source1:        siteconfig.py

# Fedora specific.
Patch:          0001-Reduce-numpy-build-dependency.patch
# Might not go upstream in current form.
Patch:          0002-Increase-tolerance-for-new-FreeType.patch

BuildRequires:  gcc-c++
BuildRequires:  proj-data-uk
BuildRequires:  python3-devel

%global _description %{expand:
Cartopy is a Python package designed to make drawing maps for data analysis
and visualisation easy. It features:
* object oriented projection definitions
* point, line, polygon and image transformations between projections
* integration to expose advanced mapping in Matplotlib with a simple and
  intuitive interface
* powerful vector data handling by integrating shapefile reading with Shapely
  capabilities
}

%description %{_description}


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

Requires:       python-%{srcname}-common = %{version}-%{release}
Recommends:     python3dist(cartopy[ows]) = %{version}-%{release}
Recommends:     python3dist(cartopy[plotting]) = %{version}-%{release}
%ifnarch %{ix86}
Recommends:     python3dist(cartopy[speedups]) = %{version}-%{release}
%endif

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


%package -n     python-%{srcname}-common
Summary:        Data files for %{srcname}
BuildArch:      noarch

BuildRequires:  natural-earth-map-data-110m
BuildRequires:  natural-earth-map-data-50m

Recommends:     natural-earth-map-data-110m
Suggests:       natural-earth-map-data-50m
Suggests:       natural-earth-map-data-10m

%description -n python-%{srcname}-common
Data files for %{srcname}.


%ifnarch %{ix86}
%pyproject_extras_subpkg -n python3-cartopy ows plotting speedups
%else
%pyproject_extras_subpkg -n python3-cartopy ows plotting
%endif


%prep
%autosetup -n %{srcname}-%{version} -p1
cp -a %SOURCE1 lib/cartopy/

sed -i -e 's/, "pytest-cov", "coveralls"//g' pyproject.toml

# Remove generated Cython sources
rm lib/cartopy/trace.cpp


%generate_buildrequires
%ifnarch %{ix86}
%pyproject_buildrequires -r -x ows,plotting,speedups,test
%else
%pyproject_buildrequires -r -x ows,plotting,test
%endif


%build
export FORCE_CYTHON=1 SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files -l %{srcname}

mkdir -p %{buildroot}%{_datadir}/cartopy/shapefiles/natural_earth/
for theme in physical cultural; do
    ln -s %{_datadir}/natural-earth-map-data/${theme} \
        %{buildroot}%{_datadir}/cartopy/shapefiles/natural_earth/${theme}
done


%check
MPLBACKEND=Agg \
    %{pytest} -n auto --doctest-modules --mpl --mpl-generate-summary=html --pyargs cartopy \
%if %{with network}
    %{nil}
%else
    -m "not network"
%endif


%files -n python-%{srcname}-common
%doc README.md
%{_datadir}/cartopy/

%files -n python3-%{srcname} -f %{pyproject_files}
%{_bindir}/cartopy_feature_download


%changelog
## START: Generated by rpmautospec
* Tue Oct 08 2024 Packit <hello@packit.dev> - 0.24.1-1
- Update to 0.24.1 upstream release
- Resolves: rhbz#2317031

* Tue Oct 08 2024 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.24.0-1
- Update to latest version (#2317031)

* Tue Oct 08 2024 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.23.0-4
- Configure Packit for release automation

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

* Wed Jun 26 2024 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.23.0-2
- Correct license tag

* Tue Jun 25 2024 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.23.0-1
- Update to latest version (#2274386)

* Wed Jun 19 2024 Python Maint <python-maint@redhat.com> - 0.22.0-6
- Rebuilt for Python 3.13

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

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

* Thu Sep 14 2023 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.22.0-3
- Fix tests with Matplotlib 3.8.0

* Fri Aug 11 2023 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.22.0-2
- Drop speedups on i686

* Fri Aug 11 2023 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.22.0-1
- Update to latest version (#2229333)

* Wed Jul 19 2023 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.21.1-6
- Fix tests with Proj 9.2

* Wed Jul 19 2023 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.21.1-5
- Rebuild for Python 3.12b4

* Sat Apr 08 2023 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.21.1-4
- Update to SPDX license

* Wed Mar 01 2023 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.21.1-3
- Backport fix for Matplotlib 3.7

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

* Tue Dec 13 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.21.1-1
- Update to latest version (#2152747)

* Fri Sep 16 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.21.0-1
- Update to latest version (#2125749)

* Sun Aug 21 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.20.3-4
- Fix compatibility with Matplotlib 3.6

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

* Thu Jun 30 2022 Lumir Balhar <lbalhar@redhat.com> - 0.20.3-2
- Allow the latest setuptools_scm 7

* Wed Jun 29 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.20.3-1
- Update to latest version (#2101991)

* Tue Jun 21 2022 Python Maint <python-maint@redhat.com> - 0.20.2-3
- Rebuilt for Python 3.11

* Mon May 23 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.20.2-1
- Update to latest version (#2040130)

* Mon May 23 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.20.1-4
- Fix FTBFS due to broken rpath

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.20.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Thu Oct 21 2021 Sandro Mani <manisandro@gmail.com> - 0.19.0-4
- Rebuild (geos)

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.19.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 0.19.0-2
- Rebuilt for Python 3.10

* Thu Apr 22 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.19.0-1
- Update to latest version (#1952194)

* Tue Mar 23 2021 Sandro Mani <manisandro@gmail.com> - 0.19.0~rc1-3
- Rebuild (geos)

* Tue Mar 23 2021 Sandro Mani <manisandro@gmail.com> - 0.19.0~rc1-2
- Bundle proj 7, as cartopy does not build against proj8

* Sat Mar 13 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.19.0~rc1-1
- Update to latest version (#1938248)

* Sun Mar 07 2021 Sandro Mani <manisandro@gmail.com> - 0.18.0-7
- Rebuild (proj)

* Sat Feb 13 2021 Sandro Mani <manisandro@gmail.com> - 0.18.0-6
- Rebuild (geos)

* Sat Jan 30 2021 Jos de Kloe <josdekloe@gmail.com> 0.18.0-5
- Add a patch to fix build failures caused by np.float deprecation
- Modify patch to add more tolerance to image comparisons
- skip test_grid_labels, since it seems to suffer from a bug that is
  not yet solved upstream

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.18.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Wed Nov 11 13:06:18 CET 2020 Sandro Mani <manisandro@gmail.com> - 0.18.0-4
- Rebuild (proj, gdal)

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.18.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 0.18.0-2
- Rebuilt for Python 3.9

* Mon May 18 2020 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.18.0-1
- Update to latest version

* Fri May 01 2020 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.18.0~rc1-1
- Update to latest release candidate

* Mon Apr 13 2020 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.18.0~b2-1
- Update to latest beta

* Mon Feb 10 2020 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.18.0~b1-1
- Update to latest beta

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.17.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.17.0-7
- Rebuilt for Python 3.8

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.17.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Fri May 31 2019 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.17.0-5
- Fix build against FreeType 2.10.0

* Tue Feb 12 2019 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.17.0-4
- Rebuilt for updated Proj

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.17.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Thu Dec 06 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.17.0-2
- Remove pytest bytecode

* Sat Nov 17 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.17.0-1
- Update to latest version
- Remove workaround for unpackaged Natural Earth data
- Drop Python 2 subpackage

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Wed Jul 11 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.16.0-5
- Add explicit gcc-c++ BR

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.16.0-4
- Rebuilt for Python 3.7

* Wed Feb 28 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.16.0-3
- Drop patch for old versions of Matplotlib.
- Use python2- prefix for dependencies.

* Sun Feb 25 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.16.0-2
- Enable testing with now-packaged Natural Earth data.

* Fri Feb 23 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.16.0-1
- Initial package.

## END: Generated by rpmautospec