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

# Sphinx-generated HTML documentation is not suitable for packaging; see
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
#
# We can generate PDF documentation as a substitute.
%bcond_without doc_pdf

Name:           python-shapely
Version:        1.8.5.post1
Release:        %autorelease
Summary:        Manipulation and analysis of geometric objects in the Cartesian plane

License:        BSD-3-Clause
URL:            https://github.com/shapely/shapely
Source0:        %{url}/archive/%{version}/shapely-%{version}.tar.gz

# Revert "BLD: avoid using latest setuptools for building 1.8.x (#1481)"
#
# This reverts commit f25c3ff57e7afcde8db7c35a7ec01c9195c4655e.
#
# The setuptools version was upper-bounded due to changes in editable
# installations, but these are not relevant for building distribution
# packages.
#
# See also https://github.com/shapely/shapely/pull/1481, where the version cap
# was discussed and added upstream.
Patch:          0001-Revert-BLD-avoid-using-latest-setuptools-for-buildin.patch

BuildRequires:  gcc
BuildRequires:  geos-devel

BuildRequires:  python3-devel

# Vendored upstream, but we remove the vendored copy:
BuildRequires:  python3dist(packaging)

%if %{with doc_pdf}
BuildRequires:  make
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk
%endif

%global _description %{expand:
Shapely is a package for creation, manipulation, and analysis of planar
geometry objects – designed especially for developers of cutting edge
geographic information systems. In a nutshell: Shapely lets you do PostGIS-ish
stuff outside the context of a database using idiomatic Python.

You can use this package with python-matplotlib and numpy. See README.rst for
more information!}

%description %_description


%pyproject_extras_subpkg -n python3-shapely vectorized


%package -n python3-shapely
Summary:        Manipulation and analysis of geometric objects in the Cartesian plane

%description -n python3-shapely %_description


%package doc
Summary:        Documentation for %{name}
BuildArch:      noarch

%description doc %_description


%prep
%autosetup -n shapely-%{version} -p1

# Remove vendored python-packaging
rm -rvf _vendor
sed -r -i 's/_vendor\.//g' setup.py

# Currently, the GitHub tarball does not ship with pre-generated Cython C
# sources. We preventively check for them anyway, as they must be removed if
# they do appear.
find . -type f -name '*.c' -print -delete

# We don’t need the “oldest supported numpy” in the RPM build, and the
# metapackage in question (https://pypi.org/project/oldest-supported-numpy/) is
# not packaged. Just depend on numpy.
sed -r -i 's/oldest-supported-(numpy)/\1/' 'pyproject.toml'

# We can use requirements-dev.txt to get extra dependencies for the
# documentation, but we must loosen exact-version pins to allow newer versions,
# and we must drop the dependency on descartes.
#
# While python3dist(descartes) is needed for a complete documentation build, it
# no longer has an upstream; its tests started failing in Fedora
# (RHBZ#1907389); and it was retired after F34. See
# https://github.com/shapely/shapely/issues/1145. The documentation is still
# useful without it.
sed -r  \
    -e 's/==/>=/' \
    -e '/\bdescartes\b/d' \
    'requirements-dev.txt' | tee 'requirements-dev-filtered.txt'


%generate_buildrequires
# Extra “all” is currently “vectorized”+“test”.
%pyproject_buildrequires -x all requirements-dev-filtered.txt


%build
%pyproject_wheel

%if %{with doc_pdf}
# We can build documentation without the optional compiled vectorized
# extensions, but we use the “built” copy of the package instead since it easy
# enough to do so.
PYTHONPATH="%{pyproject_build_lib}" \
    %make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}'
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
%endif


%install
%pyproject_install
%pyproject_save_files shapely


%check
# Ensure the “un-built” package is not imported. Otherwise compiled extensions
# cannot be tested.
mkdir empty
cd empty
ln -s ../tests/

%pytest


%files -n python3-shapely -f %{pyproject_files}
# pyproject-rpm-macros handles LICENSE.txt; verify with “rpm -qL -p …”
%exclude %{python3_sitearch}/shapely/examples/


%files doc
%license LICENSE.txt

%doc CHANGES.txt
%doc CITATION.txt
%doc CODE_OF_CONDUCT.md
%doc CREDITS.txt
%doc FAQ.rst
%doc GEOS-C-API.txt
%doc README.rst

%doc docs/design.rst

%if %{with doc_pdf}
%doc docs/_build/latex/Shapely.pdf
%endif

%doc shapely/examples/


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

* Fri Oct 14 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.5.post1-1
- Update to 1.8.5.post1

* Wed Sep 07 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.4-2
- Permit setuptools >= 64
- Reverts upstream commit f25c3ff57e7afcde8db7c35a7ec01c9195c4655e

* Thu Aug 18 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.4-1
- Update to 1.8.4

* Thu Aug 04 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.2-9
- Build docs against package with compiled extensions

* Thu Aug 04 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.2-8
- Build LaTeX more quietly

* Thu Aug 04 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.2-7
- Update License to SPDX (BSD → BSD-3-Clause)

* Sun Jul 24 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.2-6
- Update parallel offset test for GEOS 3.11

* Sun Jul 24 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.2-5
- Stop excluding C source files and Cython sources
- Installing .pyx files is potentially useful for debugging, and most
  upstreams seem to prefer to distribute these
- The build no longer installs C sources on F37+, so we do not have to
  exclude them.

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

* Thu Jun 23 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.2-3
- Stop filtering requirements-dev.txt in-place

* Wed Jun 15 2022 Python Maint <python-maint@redhat.com> 1.8.2-2
- Rebuilt for Python 3.11

* Tue May 03 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.2-1
- Update to 1.8.2

* Tue May 03 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.1~post1-2
- Drop the “forge” macros, which are not doing much here

* Fri Feb 18 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.1~post1-1
- Update to 1.8.1.post1

* Wed Feb 16 2022 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.1-1
- Update to 1.8.1

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

* Mon Oct 25 2021 Benjamin A. Beasley <code@musicinmybrain.net> 1.8.0-1
- Update to 1.8.0 (final)

* Thu Oct 21 2021 Benjamin A. Beasley <code@musicinmybrain.net> 1.8~rc2-1
- Update to 1.8.0rc2 and use pyproject-rpm-macros

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

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

* Wed Jul 07 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-11
- Update spec file comment regarding now-retired python3dist(descartes)

* Sun Jun 06 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-10
- Drop descartes BR altogether, as that package seems unlikely to be fixed
  (RHBZ#1907389); we will just build the documentation without it

* Sat Jun 05 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-9
- Disable “descartes” conditional to break the circular dependency for Python
  3.10
- Drop Fedora 32 %%py_provides

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

* Thu Mar 11 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-7
- Rename bootstrap conditional to “descartes”
- Fix skipped tests for vectorized extensions
- Fix tests that failed on s390x because they assumed the host was
  little-endian (RHBZ#1937719,
  https://github.com/Toblerity/Shapely/issues/1102)

* Thu Mar 11 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-6
- Switch to python3dist(…) style BR’s

* Thu Mar 11 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-5
- Add bootstrap conditional to break circular dependency with python-descartes,
  used for HTML documentation

* Wed Mar 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-4
- Use %%url macro to shorten Source0 URL
- Use expand: to clean up description macro
- Improve whitespace consistency
- Drop python_provide macro, which is obsolete in Fedora
- Fix SvgTestCase.test_collection failing with geos 3.9.0
  (https://github.com/Toblerity/Shapely/issues/1079, RHBZ #1907955)
- Improve handling of Cython and Cython-generated C source files
- Use the %%pytest macro instead of deprecated “python3 setup.py test”; this
  also ensures we test the built package rather than re-compiling extensions in
  %%check
- Add metapackage for “vectorized” extra
- Install LICENSE.txt
- Add a -doc subpackage and build the HTML documentation
- Work around s390x test failures; RHBZ to be filed

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

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

* Fri Aug 21 2020 Volker Fröhlich <volker27@gmx.at> - 1.7.1-1
- New upstream release

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

* Wed Jun 17 2020 Miro Hrončok <mhroncok@redhat.com> - 1.7.0-4
- Update to 1.7.0 final (#1795751)

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

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

* Fri Jan 17 2020 Volker Fröhlich <volker27@gmx.at> - 1.7-1.b1

* Tue Jan 07 2020 Volker Fröhlich <volker27@gmx.at> - 1.7-1.a3
- New upstream release
- Don't run cython on our own
- Change source URL
- Remove generated C file unconditionally

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

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

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

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

* Fri Jan 04 2019 Miro Hrončok <mhroncok@redhat.com> - 1.6.4-5.post2
- Remove python2 subpackage

* Thu Aug 02 2018 Volker Fröhlich <volker27@gmx.at> - 1.6.4-4.post2
- New upstream release
- Add missing BR on gcc (Cython)

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.4-3.post1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Thu Jul 05 2018 Volker Fröhlich <volker27@gmx.at> - 1.6.4-2.post1
- Merge Miro's pull request removing filter_provides and
  correcting the python_provide macro; Also adding it to the Python 3
  sub-package

* Wed Jul 04 2018 Volker Fröhlich <volker27@gmx.at> - 1.6.4-1.post1
- New upstream release
- Use unambiguous python2 macros

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

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

* Fri Feb 16 2018 2018 Lumír Balhar <lbalhar@redhat.com> - 1.5.16-11
- Fix directory ownership

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

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

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.16-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

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

* Fri Jul 07 2017 Igor Gnatenko <ignatenko@redhat.com> - 1.5.16-6
- Rebuild due to bug in RPM (RHBZ #1468476)

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

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

* Sat Oct 15 2016 Peter Robinson <pbrobinson@fedoraproject.org> - 1.5.16-3
- rebuilt for matplotlib-2.0.0

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

* Sat May 28 2016 Volker Fröhlich <volker27@gmx.at> - 1.5.16-1
- New upstream release

* Tue Mar 29 2016 Volker Fröhlich <volker27@gmx.at> - 1.5.15-1
- New upstream release

* Wed Mar 02 2016 Miro Hrončok <mhroncok@redhat.com> - 1.5.13-1
- Update to 1.5.13 (#1181550)
- BR pytest and matplotlib for tests

* Wed Mar 02 2016 Miro Hrončok <mhroncok@redhat.com> - 1.5.13-1
- Update to 1.5.13 (#1181550)
- BR pytest and matplotlib for tests

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

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

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

* Mon Jan  5 2015 Volker Fröhlich <volker27@gmx.at> - 1.5.2-1
- New upstream release

* Sat Dec  6 2014 Volker Fröhlich <volker27@gmx.at> - 1.5.1-1
- New upstream release

* Tue Nov  4 2014 Volker Fröhlich <volker27@gmx.at> - 1.4.4-1
- New upstream release

* Wed Oct  8 2014 Volker Fröhlich <volker27@gmx.at> - 1.4.3-1
- New upstream release

* Tue Sep 30 2014 Volker Fröhlich <volker27@gmx.at> - 1.4.2-1
- New upstream release

* Wed Sep 24 2014 Volker Fröhlich <volker27@gmx.at> - 1.4.1-1
- New upstream release

* Thu Sep 18 2014 Volker Fröhlich <volker27@gmx.at> - 1.4.0-1
- New upstream release
- Add BR on Cython/python3-cython and build the C extension
- Update URL
- Remove the obsolete encoding patch

* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

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

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

* Fri May 23 2014 Volker Fröhlich <volker27@gmx.at> - 1.3.2-1
- New upstream release

* Thu Apr 24 2014 Volker Fröhlich <volker27@gmx.at> - 1.3.1-1
- New upstream release

* Sat Apr 19 2014 Volker Fröhlich <volker27@gmx.at> - 1.3.0-2
- Replace obsolete python-setuptools-devel with python-setuptools

* Wed Feb 12 2014 Volker Fröhlich <volker27@gmx.at> - 1.3.0-1
- New upstream release
- Use a better summary
- Add Python 3 builds
- Change BR python-devel to python2-devel

* Mon Sep 16 2013 Volker Fröhlich <volker27@gmx.at> - 1.2.18-1
- New upstream release

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

* Sun Jan 27 2013 Volker Fröhlich <volker27@gmx.at> - 1.2.17-1
- New upstream release

* Tue Sep 18 2012 Volker Fröhlich <volker27@gmx.at> - 1.2.16-1
- New upstream release

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

* Thu Jun 28 2012 Volker Fröhlich <volker27@gmx.at> - 1.2.15-1
- New upstream release
- Pyx file is no longer part of the sources, thus Cython is no longer BR
- Chaintest is working fine now, drop the patch

* Sun Apr  8 2012 Volker Fröhlich <volker27@gmx.at> - 1.2.14-1
- Update for release 1.2.14
- Remove duplicate PKG-INFO file
- Correct description -- pointing to README.rst now
- Add patch that corrects the attribute chaining test
- Tests now work fine, therefore respect their outcome
- Remove ready-made _speedups.c

* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.13-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Tue Aug 16 2011 Volker Fröhlich <volker27@gmx.at> - 1.2.13-1
- Update for release 1.2.13

* Tue Aug 16 2011 Volker Fröhlich <volker27@gmx.at> - 1.2.12-1
- Update for release 1.2.12
- Don't ship tests
- Label examples as documentation

* Mon Aug 15 2011 Volker Fröhlich <volker27@gmx.at> - 1.2.11-2
- BR numpy for the tests

* Mon Aug 15 2011 Ville Skyttä <ville.skytta@iki.fi> - 1.2.11-2
- BR geos-devel to actually build arch specific bits
- Drop unneeded geos dep

* Fri Aug 12 2011 Volker Fröhlich <volker27@gmx.at> - 1.2.11-1
- Updated for 1.2.11
- Switch away from noarch
- Remove useless clean section and rm in install
- Debian patch to rebuild Cython .c file
- Avoid private provides for .so
- Extend package description

* Fri Apr 01 2011 Volker Fröhlich <volker27@gmx.at> - 1.2.9-1
- Updated for 1.2.9
- Added tests again, but ignore the results

* Fri Feb 25 2011 Volker Fröhlich <volker27@gmx.at> - 1.2.8-1
- Updated for 1.2.8
- Disable tests

* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.7-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Sat Nov 27 2010 Volker Fröhlich <volker27@gmx.at> - 1.2.7-2
- Explained excluded files; added check section

* Wed Nov 24 2010 Volker Fröhlich <volker27@gmx.at> - 1.2.7-1
- Initial package for Fedora