dbc7458
# Sphinx-generated HTML documentation is not suitable for packaging; see
dbc7458
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
dbc7458
#
dbc7458
# We can generate PDF documentation as a substitute.
f31fd3f
%bcond doc_pdf 1
79f7564
dbc7458
Name:           python-OWSLib
fae6a7b
Version:        0.30.0
f035bbb
Release:        %autorelease
35ad88b
Summary:        OGC Web Service utility library
dbc7458
6a7628c
License:        BSD-3-Clause
da045c3
URL:            https://geopython.github.io/OWSLib
d4c832e
%global forgeurl https://github.com/geopython/OWSLib
d4c832e
Source:         %{forgeurl}/archive/%{version}/OWSLib-%{version}.tar.gz
dbc7458
79f7564
BuildArch:      noarch
79f7564
35954f3
BuildRequires:  python3-devel
35954f3
dbc7458
%if %{with doc_pdf}
dbc7458
BuildRequires:  make
dbc7458
BuildRequires:  python3-sphinx-latex
dbc7458
BuildRequires:  latexmk
3b6e912
BuildRequires:  pandoc
dbc7458
%endif
79f7564
8168588
%global common_description %{expand:
dbc7458
OWSLib is a Python package for client programming with Open Geospatial
dbc7458
Consortium (OGC) web service (hence OWS) interface standards, and their related
dbc7458
content models.
80d6680
dbc7458
Full documentation is available at http://geopython.github.io/OWSLib
dbc7458
dbc7458
OWSLib provides a common API for accessing service metadata and wrappers for
dbc7458
numerous OGC Web Service interfaces.}
35954f3
8168588
%description %{common_description}
dbc7458
dbc7458
dbc7458
%package -n python3-OWSLib
dbc7458
Summary:        %{summary}
35954f3
887961b
%py_provides python3-owslib
887961b
8168588
%description -n python3-OWSLib %{common_description}
dbc7458
dbc7458
dbc7458
%package doc
dbc7458
Summary:        Documentation and examples for OWSLib
dbc7458
dbc7458
%description doc
dbc7458
%{summary}.
dbc7458
35954f3
79f7564
%prep
dbc7458
%autosetup -n OWSLib-%{version}
dbc7458
dbc7458
# Don’t analyze/report test coverage
dbc7458
sed -r -i 's/[-]-cov[^[:blank:]]*[[:blank:]][^[[:blank:]]+//g' tox.ini
3b6e912
# Don’t generate linting/coverage dependencies.
3b6e912
#
3b6e912
# We don’t have python3dist(pandoc) packaged, and besides, we don’t actually
3b6e912
# need python3dist(pandoc)—only the pandoc command-line tool, which we have
3b6e912
# manually BR’d.
f0ab838
#
f0ab838
# Don’t generate twine dependency, which is just for the upstream maintainer
f0ab838
# uploading to PyPI.
27e1330
sed -r -e '/^(flake8|pytest-cov|twine|coverage|coveralls)\b/d' \
cb063a5
    requirements-dev.txt | tee requirements-dev-filtered.txt
35954f3
dbc7458
# We don’t need shebangs in the examples. The pattern of selecting files
dbc7458
# before modifying them with sed keeps us from unnecessarily discarding the
dbc7458
# original mtimes on unmodified files.
dbc7458
find 'examples' -type f -name '*.py' \
dbc7458
    -exec gawk '/^#!/ { print FILENAME }; { nextfile }' '{}' '+' |
dbc7458
  xargs -r sed -r -i '1{/^#!/d}'
dbc7458
# Some of them, but not all of them, were executable.
dbc7458
chmod -v a-x examples/*.py
dbc7458
3b6e912
# Because at least one notebook requires Internet access, we must continue past
3b6e912
# notebook errors when building documentation.
27e1330
echo 'nbsphinx_allow_errors = True' >> docs/source/conf.py
3b6e912
dbc7458
dbc7458
%generate_buildrequires
27e1330
%{pyproject_buildrequires \
27e1330
    %{?with_doc_pdf:docs/requirements.txt} \
27e1330
    requirements-dev-filtered.txt}
79f7564
79f7564
79f7564
%build
dbc7458
%pyproject_wheel
79f7564
dbc7458
%if %{with doc_pdf}
07adcbd
PYTHONPATH="${PWD}" %make_build -C docs latex \
07adcbd
    SPHINXOPTS='-j%{?_smp_build_ncpus}'
27e1330
%make_build -C docs/build/latex LATEXMKOPTS='-quiet'
dbc7458
%endif
79f7564
79f7564
dbc7458
%install
dbc7458
%pyproject_install
f0f0c09
%pyproject_save_files -l owslib
dbc7458
dbc7458
dbc7458
%check
dbc7458
# Otherwise, pytest finds the package twice in the Python path and complains.
dbc7458
rm -rf owslib
dbc7458
dbc7458
# There is a convenient “online” mark for deselecting tests that require
dbc7458
# Internet access, but we still have to manually deselect doctests that try to
dbc7458
# make network requests.
dbc7458
k="${k-}${k+ and }not wms_geoserver_mass_gis.txt"
dbc7458
k="${k-}${k+ and }not wfs_MapServerWFSFeature.txt"
dbc7458
k="${k-}${k+ and }not wfs_MapServerWFSCapabilities.txt"
dbc7458
k="${k-}${k+ and }not wfs2_storedqueries.txt"
dbc7458
k="${k-}${k+ and }not wfs1_generic.txt"
dbc7458
k="${k-}${k+ and }not wcs_thredds.txt"
dbc7458
k="${k-}${k+ and }not test_wmts_example_informatievlaanderen"
dbc7458
da6b2b5
# This is a trivial error where the representation of the expected TypeError
da6b2b5
# has changed over time:
dbc7458
# Differences (unified diff with -expected +actual):
dbc7458
#     @@ -1,3 +1,6 @@
dbc7458
#      Traceback (most recent call last):
dbc7458
#     -...
dbc7458
#     -TypeError: get_namespace() ...
dbc7458
#     +  File "/usr/lib64/python3.10/doctest.py", line 1346, in __run
dbc7458
#     +    exec(compile(example.source, filename, "single",
dbc7458
#     +  File "<doctest namespaces.txt[15]>", line 1, in <module>
dbc7458
#     +    ns.get_namespace()
dbc7458
#     +TypeError: Namespaces.get_namespace() missing 1 required positional argument: 'key'
dbc7458
k="${k-}${k+ and }not namespaces.txt"
dbc7458
dbc7458
# Unknown problem—check if it is fixed in a later version:
dbc7458
k="${k-}${k+ and } not (TestOffline and test_wfs_110_remotemd_parse_all)"
dbc7458
k="${k-}${k+ and } not (TestOffline and test_wfs_110_remotemd_parse_single)"
dbc7458
k="${k-}${k+ and } not (TestOffline and test_wfs_200_remotemd_parse_all)"
dbc7458
k="${k-}${k+ and } not (TestOffline and test_wfs_200_remotemd_parse_single)"
dbc7458
k="${k-}${k+ and } not (TestOffline and test_wms_130_remotemd_parse_all)"
dbc7458
k="${k-}${k+ and } not (TestOffline and test_wms_130_remotemd_parse_single)"
dbc7458
dbc7458
%pytest -m 'not online' -k "${k-}"
dbc7458
dbc7458
dbc7458
%files -n python3-OWSLib -f %{pyproject_files}
dbc7458
dbc7458
dbc7458
%files doc
dbc7458
%license LICENSE
4435cdb
%doc AUTHORS.rst
27e1330
%doc README.md
27e1330
%doc examples/
dbc7458
%if %{with doc_pdf}
27e1330
%doc docs/build/latex/OWSLib.pdf
dbc7458
%endif
79f7564
35954f3
79f7564
%changelog
f035bbb
%autochangelog