From dbc7458fbf9de299007b3172cbb854e4f443640c Mon Sep 17 00:00:00 2001 From: Benjamin A. Beasley Date: Dec 21 2021 13:10:26 +0000 Subject: Modernize packaging; run tests; add -doc subpackage --- diff --git a/python-OWSLib.spec b/python-OWSLib.spec index cee5278..0e0cba0 100644 --- a/python-OWSLib.spec +++ b/python-OWSLib.spec @@ -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 -%description %_description +%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. -%package -n python3-OWSLib -Summary: Client library for OGC web services +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.} -Requires: python3-dateutil -Requires: python3-pyproj -Requires: python3-pytz -Requires: python3-requests +%description +%{common_description} + + +%package -n python3-OWSLib +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} + +# Don’t analyze/report test coverage +sed -r -i 's/[-]-cov[^[:blank:]]*[[:blank:]][^[[:blank:]]+//g' tox.ini +# Don’t generate linting/coverage dependencies +sed -r '/^(flake8|pytest-cov)\b/d' requirements-dev.txt \ + > requirements-dev-filtered.txt -find . -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|' +# We don’t 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 +%install +%pyproject_install +%pyproject_save_files owslib + + +%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 "", line 1, in +# + 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 -%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 %changelog %autochangelog diff --git a/sources b/sources index d02562e..fdb7ddf 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (OWSLib-0.21.0.tar.gz) = f475b07553ef96cae018a304cb809fac33d3953d8ef12135165c40de323d60fbc1f11d0b63fb5578b6c092c50cd3f3c97fc01e85e44b462cdb3f0cbd967d9fad +SHA512 (OWSLib-0.21.0.tar.gz) = 3dc28bed9041fdcae63a0296cc96660788038d8f57fe131fca7906c58161917deb1b1a90050d434ea855b33385afdf0f84baaf3bdb94e7db8df6ccff180acc43