## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 6;
    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:           pyshp
Version:        2.3.1
Release:        %autorelease
Summary:        Pure Python read/write support for ESRI Shapefile format

# SPDX
License:        MIT
URL:            https://github.com/GeospatialPython/pyshp
Source0:        %{url}/archive/%{version}/pyshp-%{version}.tar.gz

# Shapefiles for doctests. These are not packaged in the binary RPMs, so do not
# contribute to the License. They are LicenseRef-Fedora-Public-Domain
# (https://github.com/nvkelso/natural-earth-vector/blob/master/LICENSE.md; see
# also http://www.naturalearthdata.com/about/terms-of-use/). Upstream tests
# fetch these from the network.
%global ne_url https://github.com/nvkelso/natural-earth-vector
# Upstream uses “master”
%global ne_commit e6fd44e64780e9724e2c663594dafcc4da5b1cc1
Source10:       %{ne_url}/raw/%{ne_commit}/10m_cultural/ne_10m_admin_1_states_provinces.cpg
Source11:       %{ne_url}/raw/%{ne_commit}/10m_cultural/ne_10m_admin_1_states_provinces.dbf
Source12:       %{ne_url}/raw/%{ne_commit}/10m_cultural/ne_10m_admin_1_states_provinces.prj
Source13:       %{ne_url}/raw/%{ne_commit}/10m_cultural/ne_10m_admin_1_states_provinces.shp
Source14:       %{ne_url}/raw/%{ne_commit}/10m_cultural/ne_10m_admin_1_states_provinces.shx
Source20:       %{ne_url}/raw/%{ne_commit}/110m_cultural/ne_110m_admin_0_tiny_countries.cpg
Source21:       %{ne_url}/raw/%{ne_commit}/110m_cultural/ne_110m_admin_0_tiny_countries.dbf
Source22:       %{ne_url}/raw/%{ne_commit}/110m_cultural/ne_110m_admin_0_tiny_countries.prj
Source23:       %{ne_url}/raw/%{ne_commit}/110m_cultural/ne_110m_admin_0_tiny_countries.shp
Source24:       %{ne_url}/raw/%{ne_commit}/110m_cultural/ne_110m_admin_0_tiny_countries.shx
# Upstream also uses https://biogeo.ucdavis.edu/data/diva/rrd/NIC_rrd.zip, but
# the license is unclear, so we skip this one.

BuildArch:      noarch

BuildRequires:  python3-devel

BuildRequires:  dos2unix

%global common_description %{expand:
The Python Shapefile Library (PyShp) provides read and write support for the
Esri Shapefile format. The Shapefile format is a popular Geographic Information
System vector data format created by Esri. For more information about this
format please read the well-written “ESRI Shapefile Technical Description –
July 1998” located at
http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf. The Esri document
describes the shp and shx file formats.  However a third file format called dbf
is also required. This format is documented on the web as the “XBase File
Format Description” and is a simple file-based database format created in the
1960’s. For more on this specification see:
http://www.clicketyclick.dk/databases/xbase/format/index.html

Both the Esri and XBase file-formats are very simple in design and memory
efficient which is part of the reason the shapefile format remains popular
despite the numerous ways to store and exchange GIS data available today.}

%description %{common_description}


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

%py_provides python3-shapefile

%description -n python3-pyshp %{common_description}


%prep
%autosetup -p1

# Fix non-UTF-8 license file
iconv --from-code=Windows-1252 --to-code=UTF-8 --output=LICENSE.TXT.conv \
    LICENSE.TXT
touch -r LICENSE.TXT LICENSE.TXT.conv
mv LICENSE.TXT.conv LICENSE.TXT
# Fix line endings
dos2unix LICENSE.TXT changelog.txt shapefile.py

# Allow newer versions of test dependencies
sed -r -i 's/==/>=/' requirements.test.txt

# Make a copy of README.md for which we do not need network access—either by
# using local copies of the resources that would be fetched, or by skipping
# tests where the resources are not appropriate for the source RPM (unclear
# licensing).
sed -r \
  -e 's@(Reader\("https?://biogeo.*)@\1  # doctest: +SKIP@' \
  -e 's@(Reader\(")(https?://github\.com/nvkelso/natural-earth-vector/[^"]*)/([^/"?]+)(\?[^/"]*)?@\1\3@' \
  'README.md' > 'README-no-network.md'
cp -p '%{SOURCE10}' '%{SOURCE11}' '%{SOURCE12}' '%{SOURCE13}' '%{SOURCE14}' \
    '%{SOURCE20}' '%{SOURCE21}' '%{SOURCE22}' '%{SOURCE23}' '%{SOURCE24}' .


%generate_buildrequires
%pyproject_buildrequires requirements.test.txt


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files shapefile


%check
# Although shapefile.py has an integrated runner for the doctests, we run them
# with pytest because we need to skip those that require network access.
%pytest --doctest-glob='README-no-network.md' -m '(not network)'


%files -n python3-pyshp -f %{pyproject_files}
# pyproject_files handles LICENSE.TXT; verify with “rpm -qL -p …”
%doc changelog.txt
%doc README.md


%changelog
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

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

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

* Wed Nov 30 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 2.3.1-3
- Drop default -r argument to pyproject_buildrequires

* Thu Oct 20 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 2.3.1-2
- Confirm License is SPDX MIT

* Fri Jul 29 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 2.3.1-1
- Update to 2.3.1 (close RHBZ#2112193)

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

* Fri Jul 08 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 2.3.0-3
- Fix extra newline in description

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

* Sat Apr 30 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 2.3.0-1
- Update to 2.3.0 (close RHBZ#2080591)

* Wed Apr 20 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 2.2.0-2
- Stop numbering patches

* Thu Feb 03 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 2.2.0-1
- Update to 2.2.0 (close RHBZ#2050074)

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

* Thu Dec 23 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 2.1.3-7
- Remove a stray line from the description

* Sun Dec 19 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 2.1.3-6
- Migrate to pyproject-rpm-macros

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

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

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

* Fri Jan 15 2021 Gwyn Ciesla <gwync@protonmail.com> - 2.1.3-1
- 2.1.3

* Fri Sep 11 2020 Gwyn Ciesla <gwync@protonmail.com> - 2.1.2-1
- 2.1.2

* Thu Sep 10 2020 Gwyn Ciesla <gwync@protonmail.com> - 2.1.1-1
- 2.1.1

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

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

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

* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 2.1.0-4
- Rebuilt for Python 3.8.0rc1 (#1748018)

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

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

* Sun Feb 17 2019 Volker Fröhlich <volker27@gmx.at> - 2.1.0-1
- New upstream release

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

* Tue Dec 04 2018 Volker Fröhlich <volker27@gmx.at> - 2.0.1-1
- New upstream release
- Drop python2 sub-package

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

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

* Fri Feb 09 2018 Iryna Shcherbina <ishcherb@redhat.com> - 1.2.12-3
- Update Python 2 dependency declarations to new packaging standards
  (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.12-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Fri Aug 25 2017 Volker Fröhlich <volker27@gmx.at> - 1.2.12-1
- New upstream release

* Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 1.2.11-3
- Python 2 binary package renamed to python2-pyshp
  See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.11-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Sun Apr 30 2017 Volker Fröhlich <volker27@gmx.at> - 1.2.11-1
- New upstream release

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.10-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 1.2.10-2
- Rebuild for Python 3.6

* Sun Sep 25 2016 Volker Fröhlich <volker27@gmx.at> - 1.2.10-1
- New upstream release

* Tue Aug 30 2016 Volker Fröhlich <volker27@gmx.at> - 1.2.5-2
- Add LICENSE.TXT to cp

* Mon Aug 29 2016 Volker Fröhlich <volker27@gmx.at> - 1.2.5-1
- New upstream release
- Add license file, change README extension

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.3-4
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.3-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5

* Mon Jun 22 2015 Volker Fröhlich <volker27@gmx.at> - 1.2.3-1
- New upstream release
- Modernize the process of constructing a Python 3 sub-package
- Ship README and changelog with both packages
- Update homepage and source URL

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Tue May 27 2014 Kalev Lember <kalevlember@gmail.com> - 1.2.1-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4

* Mon May 12 2014 Volker Fröhlich <volker27@gmx.at> - 1.2.1-1
- New upstream release
- Properly check on Python 3 builds

* Thu Jan 23 2014 Volker Fröhlich <volker27@gmx.at> - 1.2.0-2
- Disable Python 3 builds for EPEL7 until Python 3 is available there

* Sun Oct 06 2013 Volker Fröhlich <volker27@gmx.at> - 1.2.0-1
- New upstream release

* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.4-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.4-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Sat Aug 04 2012 David Malcolm <dmalcolm@redhat.com> - 1.1.4-5
- rebuild for https://fedoraproject.org/wiki/Features/Python_3.3

* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Sat May 19 2012 Volker Fröhlich <volker27@gmx.at> - 1.1.4-3
- Move BR python3-devel in conditional block

* Fri May 18 2012 Volker Fröhlich <volker27@gmx.at> - 1.1.4-2
- Run doctests
- Delete the original egg-info

* Sun Apr 22 2012 Volker Fröhlich <volker27@gmx.at> - 1.1.4-1
- Initial package for Fedora