Modernize packaging; run tests; add -doc subpackage

This commit is contained in:
Benjamin A. Beasley 2021-12-21 01:24:38 -05:00
commit dbc7458fbf
2 changed files with 120 additions and 28 deletions

View file

@ -1,56 +1,148 @@
# Works with either ElementTree or python-lxml
%global modname OWSLib
# 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-%{modname}
Name: python-OWSLib
Version: 0.21.0
Release: %autorelease
Summary: Client library for OGC web services
License: BSD
URL: https://geopython.github.io/OWSLib
Source0: https://files.pythonhosted.org/packages/source/O/%{modname}/%{modname}-%{version}.tar.gz
Source0: https://github.com/geopython/OWSLib/archive/%{version}/OWSLib-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-setuptools
%global _description\
Package for client programming with Open Geospatial Consortium (OGC) web\
service (hence OWS) interface standards, and their related content models.
%if %{with doc_pdf}
BuildRequires: make
BuildRequires: python3-sphinx-latex
BuildRequires: latexmk
%endif
%global common_description %{expand: \
OWSLib is a Python package for client programming with Open Geospatial
Consortium (OGC) web service (hence OWS) interface standards, and their related
content models.
Full documentation is available at http://geopython.github.io/OWSLib
OWSLib provides a common API for accessing service metadata and wrappers for
numerous OGC Web Service interfaces.}
%description
%{common_description}
%description %_description
%package -n python3-OWSLib
Summary: Client library for OGC web services
Requires: python3-dateutil
Requires: python3-pyproj
Requires: python3-pytz
Requires: python3-requests
Summary: %{summary}
%description -n python3-OWSLib
Package for client programming with Open Geospatial Consortium (OGC) web
service (hence OWS) interface standards, and their related content models.
%{common_description}
%package doc
Summary: Documentation and examples for OWSLib
%description doc
%{summary}.
%prep
%setup -q -n %{modname}-%{version}
rm -rf %{modname}.egg-info
%autosetup -n OWSLib-%{version}
find . -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
# Dont analyze/report test coverage
sed -r -i 's/[-]-cov[^[:blank:]]*[[:blank:]][^[[:blank:]]+//g' tox.ini
# Dont generate linting/coverage dependencies
sed -r '/^(flake8|pytest-cov)\b/d' requirements-dev.txt \
> requirements-dev-filtered.txt
# We dont need shebangs in the examples. The pattern of selecting files
# before modifying them with sed keeps us from unnecessarily discarding the
# original mtimes on unmodified files.
find 'examples' -type f -name '*.py' \
-exec gawk '/^#!/ { print FILENAME }; { nextfile }' '{}' '+' |
xargs -r sed -r -i '1{/^#!/d}'
# Some of them, but not all of them, were executable.
chmod -v a-x examples/*.py
%generate_buildrequires
%pyproject_buildrequires -r requirements-dev-filtered.txt
%build
%py3_build
%pyproject_wheel
%if %{with doc_pdf}
%make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}'
%make_build -C docs/build/latex/en LATEXMKOPTS='-quiet'
%endif
%install
%py3_install
%pyproject_install
%pyproject_save_files owslib
%files -n python3-OWSLib
%doc README.rst CHANGES.rst AUTHORS.rst
# TODO: Add LICENSE on the next release after 0.17.0
%{python3_sitelib}/owslib
%{python3_sitelib}/%{modname}-%{version}-py*.egg-info
%check
# Otherwise, pytest finds the package twice in the Python path and complains.
rm -rf owslib
# There is a convenient “online” mark for deselecting tests that require
# Internet access, but we still have to manually deselect doctests that try to
# make network requests.
k="${k-}${k+ and }not wms_geoserver_mass_gis.txt"
k="${k-}${k+ and }not wfs_MapServerWFSFeature.txt"
k="${k-}${k+ and }not wfs_MapServerWFSCapabilities.txt"
k="${k-}${k+ and }not wfs2_storedqueries.txt"
k="${k-}${k+ and }not wfs1_generic.txt"
k="${k-}${k+ and }not wcs_thredds.txt"
k="${k-}${k+ and }not test_wmts_example_informatievlaanderen"
# This is a trivial error where the representation of the expected TypeEror has
# changed over time:
# Differences (unified diff with -expected +actual):
# @@ -1,3 +1,6 @@
# Traceback (most recent call last):
# -...
# -TypeError: get_namespace() ...
# + File "/usr/lib64/python3.10/doctest.py", line 1346, in __run
# + exec(compile(example.source, filename, "single",
# + File "<doctest namespaces.txt[15]>", line 1, in <module>
# + ns.get_namespace()
# +TypeError: Namespaces.get_namespace() missing 1 required positional argument: 'key'
k="${k-}${k+ and }not namespaces.txt"
# Unknown problem—check if it is fixed in a later version:
k="${k-}${k+ and } not (TestOffline and test_wfs_110_remotemd_parse_all)"
k="${k-}${k+ and } not (TestOffline and test_wfs_110_remotemd_parse_single)"
k="${k-}${k+ and } not (TestOffline and test_wfs_200_remotemd_parse_all)"
k="${k-}${k+ and } not (TestOffline and test_wfs_200_remotemd_parse_single)"
k="${k-}${k+ and } not (TestOffline and test_wms_130_remotemd_parse_all)"
k="${k-}${k+ and } not (TestOffline and test_wms_130_remotemd_parse_single)"
%pytest -m 'not online' -k "${k-}"
%files -n python3-OWSLib -f %{pyproject_files}
# pyproject_files handles LICENSE; verify with “rpm -qL -p …”
%doc AUTHORS.rst
%doc CHANGES.rst
%doc README.rst
%files doc
%license LICENSE
%doc examples
%if %{with doc_pdf}
%doc docs/build/latex/en/OWSLib.pdf
%endif
%changelog
%autochangelog

View file

@ -1 +1 @@
SHA512 (OWSLib-0.21.0.tar.gz) = f475b07553ef96cae018a304cb809fac33d3953d8ef12135165c40de323d60fbc1f11d0b63fb5578b6c092c50cd3f3c97fc01e85e44b462cdb3f0cbd967d9fad
SHA512 (OWSLib-0.21.0.tar.gz) = 3dc28bed9041fdcae63a0296cc96660788038d8f57fe131fca7906c58161917deb1b1a90050d434ea855b33385afdf0f84baaf3bdb94e7db8df6ccff180acc43