%global python3_pkgversion 3.11 # 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. # # This must remain disabled until python-matplotlib is available: # https://bugzilla.redhat.com/show_bug.cgi?id=2041315 %bcond_with doc_pdf Name: python-shapely Version: 1.8.2 Release: 2.ac15.py3.11%{?dist} 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 BuildRequires: gcc BuildRequires: geos-devel BuildRequires: python%{python3_pkgversion}-devel # Vendored upstream, but we remove the vendored copy: BuildRequires: python%{python3_pkgversion}dist(packaging) %if %{with doc_pdf} BuildRequires: make BuildRequires: python%{python3_pkgversion}dist(sphinx) BuildRequires: python%{python3_pkgversion}-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 python%{python3_pkgversion}-shapely Summary: Manipulation and analysis of geometric objects in the Cartesian plane %description -n python%{python3_pkgversion}-shapely %_description %package doc Summary: Documentation for %{name} BuildArch: noarch %description doc %_description %prep %autosetup -n shapely-%{version} # 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' # From CHANGES.txt: # - Require Cython >= 0.29.24 to support Python 3.10 (#1224). # Since EPEL9 has Python 3.9 (and currently only Cython 0.29.22), we can safely # loosen this minimum version. sed -r -i 's/(cython>=0\.29\.2)4/\12/' \ pyproject.toml requirements-dev.txt # 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. # # Currently, python3dist(matplotlib) is not available in EPEL9: # https://bugzilla.redhat.com/show_bug.cgi?id=2041315 sed -r \ -e 's/==/>=/' \ -e '/\bdescartes\b/d' \ -e '/\bmatplotlib\b/d' \ 'requirements-dev.txt' | tee 'requirements-dev-filtered.txt' sed -i -re "/subprocess.check_call/ s|cython|cython-%{python3_pkgversion}|" setup.py %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 for b in $(find %{buildroot}%{_bindir}/ -type f) ; do mv "$b" $(sed -re "s|(.*)$|\1-%{python3_pkgversion}|"<<<"$b"); done for m in $(find %{buildroot}%{_mandir}/ -type f) ; do mv "$m" $(sed -re "s|(.*).([1-8])(.*)$|\1-%{python3_pkgversion}.\2\3|"<<<"$m"); done for m in $(find %{buildroot}%{_datadir}/locale/* -type f) ; do mv "$m" $(sed -re "s|(.*).mo$|\1-%{python3_pkgversion}.mo|"<<<"$m"); done for l in $(find %{buildroot}/usr/lib64/lib* -type f -o -type l) ; do mv "$l" $(sed -re "s|(.*).so(.*)$|\1-py%{python3_pkgversion}.so\2|"<<<"$l"); done for p in $(find %{buildroot}/usr/lib64/pkgconfig/* -type f) ; do mv "$p" $(sed -re "s|(.*).pc$|\1-py%{python3_pkgversion}.pc|"<<<"$p"); done %files -n python%{python3_pkgversion}-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 * Mon Apr 29 2024 Ding-Yi Chen - 1.8.2-2.ac15.py3.11 - Cut corner packaging