Blob Blame History Raw
# Sphinx-generated HTML documentation is not suitable for packaging; see
# for discussion.
# We can generate PDF documentation as a substitute.
%bcond_without doc_pdf

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

License:        BSD
Source0:        %{url}/archive/%{version}/shapely-%{version}.tar.gz

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

%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

%autosetup -n shapely-%{version}

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

# 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 ( 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
# The documentation is still
# useful without it.
sed -r  \
    -e 's/==/>=/' \
    -e '/\bdescartes\b/d' \
    'requirements-dev.txt' | tee 'requirements-dev-filtered.txt'

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


%if %{with doc_pdf}
# Note that this will use the “un-built” copy without compiled vectorized
# extensions. Since these are optional, this is fine for the documentation.
# See for an example of
# installing the built wheel in a temporary directory and adding that to the
# PYTHONPATH for the documentation build.
%make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}'
%make_build -C docs/_build/latex

%pyproject_save_files shapely

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


%files -n python3-shapely -f %{pyproject_files}
# pyproject-rpm-macros handles LICENSE.txt; verify with “rpm -qL -p …”
%exclude %{python3_sitearch}/shapely/examples/
# Ensure that neither Cython source files nor Cython-generated C source files
# are installed; they are not useful.
%exclude %{python3_sitearch}/shapely/speedups/_speedups.c
%exclude %{python3_sitearch}/shapely/speedups/_speedups.pyx
%exclude %{python3_sitearch}/shapely/vectorized/_vectorized.c
%exclude %{python3_sitearch}/shapely/vectorized/_vectorized.pyx

%files doc
%license LICENSE.txt

%doc CHANGES.txt
%doc CITATION.txt
%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

%doc shapely/examples/