fd2f6a5
# Sphinx-generated HTML documentation is not suitable for packaging; see
fd2f6a5
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
fd2f6a5
#
fd2f6a5
# We can generate PDF documentation as a substitute.
3809938
%bcond doc_pdf 1
fd2f6a5
ea98903
Name:           python-ZConfig
1629eb0
Version:        4.0
63c278d
Release:        %autorelease
ea98903
Summary:        Structured Configuration Library
90813df
1601f6b
License:        ZPL-2.1
ebe9009
URL:            https://github.com/zopefoundation/ZConfig/
1735387
Source0:        %{pypi_source ZConfig}
6059611
# Man pages hand-written for Fedora in groff_man(7) format based on --help
6059611
Source1:        zconfig.1
6059611
Source2:        zconfig_schema2html.1
ea98903
ea98903
BuildArch:      noarch
266990f
266990f
BuildRequires:  python3-devel
ea98903
1b5ecf0
BuildRequires:  symlinks
1b5ecf0
fd2f6a5
%if %{with doc_pdf}
fd2f6a5
# Documentation
fd2f6a5
BuildRequires:  make
fd2f6a5
BuildRequires:  python3dist(sphinx)
fd2f6a5
BuildRequires:  python3-sphinx-latex
fd2f6a5
BuildRequires:  latexmk
fd2f6a5
%endif
fd2f6a5
7a29d92
%global common_description %{expand:
7a29d92
ZConfig is a configuration library intended for general use. It supports a
7a29d92
hierarchical schema-driven configuration model that allows a schema to specify
7a29d92
data conversion routines written in Python. ZConfig’s model is very different
7a29d92
from the model supported by the ConfigParser module found in Python’s standard
7a29d92
library, and is more suitable to configuration-intensive applications.
7a29d92
7a29d92
ZConfig schema are written in an XML-based language and are able to “import”
7a29d92
schema components provided by Python packages. Since components are able to
7a29d92
bind to conversion functions provided by Python code in the package (or
7a29d92
elsewhere), configuration objects can be arbitrarily complex, with values that
7a29d92
have been verified against arbitrary constraints. This makes it easy for
7a29d92
applications to separate configuration support from configuration loading even
7a29d92
with configuration data being defined and consumed by a wide range of separate
7a29d92
packages.}
7a29d92
7a29d92
%description %{common_description}
ea98903
90813df
266990f
%package -n python3-ZConfig
266990f
Summary:        Structured Configuration Library
90813df
7a29d92
%description -n python3-ZConfig %{common_description}
266990f
ea98903
bb8ad21
%package -n python3-ZConfig+test
bb8ad21
Summary:        Tests and test extras for ZConfig
bb8ad21
bb8ad21
Requires:       python3-ZConfig = %{version}-%{release}
bb8ad21
bb8ad21
%description -n python3-ZConfig+test
bb8ad21
These are the tests for python3-ZConfig. This package:
bb8ad21
bb8ad21
• Provides the “ZConfig.tests” package
bb8ad21
• Makes sure the “test” extra dependencies are installed
bb8ad21
bb8ad21
fd2f6a5
%package doc
fd2f6a5
Summary:        Documentation for ZConfig
fd2f6a5
fd2f6a5
# We have a symlink to a text file in the installed package.
fd2f6a5
Requires:       python3-ZConfig = %{version}-%{release}
fd2f6a5
fd2f6a5
%description doc %{common_description}
fd2f6a5
fd2f6a5
This package contains the documentation for ZConfig.
fd2f6a5
fd2f6a5
ea98903
%prep
89cdfb3
%autosetup -n ZConfig-%{version} -p1
ea98903
fd2f6a5
# We can’t cross-reference Internet documentation.
a18e29f
echo 'intersphinx_mapping.clear()' >> docs/conf.py
fd2f6a5
ea98903
4e77b85
%generate_buildrequires
fd2f6a5
%pyproject_buildrequires -x test%{?with_doc_pdf:,docs}
4e77b85
4e77b85
ea98903
%build
4e77b85
%pyproject_wheel
ea98903
90813df
ea98903
%install
4e77b85
%pyproject_install
4e77b85
%pyproject_save_files ZConfig
4e77b85
6059611
install -t '%{buildroot}%{_mandir}/man1' -p -m 0644 -D \
6059611
    '%{SOURCE1}' '%{SOURCE2}'
6059611
f564433
%if %{with doc_pdf}
f564433
# Building documentation in the install section is “weird,” but the
f564433
# documentation needs to incorporate the --help output from the command-line
f564433
# tools (via sphinxcontrib-programoutput), and those entry points are not
f564433
# generated until the wheel is installed, so this is the “least-worst”
f564433
# workaround.
f564433
PYTHONPATH='%{buildroot}%{python3_sitelib}' PATH="${PATH}:%{buildroot}%{_bindir}" \
5918e38
    %make_build -C docs latex SPHINXOPTS='-j%{?_smp_build_ncpus}'
a18e29f
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
f564433
%endif
f564433
4e77b85
# We can’t move the file ZConfig/schemaless.txt out of the package because
4e77b85
# there is a test that actually checks for its presence. We can at least mark
4e77b85
# it as documentation in-place.
4e77b85
sed -r -i 's/^.*schemaless.txt/%doc &/' '%{pyproject_files}'
4e77b85
# Since we have one documentation file installed with an absolute path, the
4e77b85
# rest need to be that way too.
fd2f6a5
install -p -m 0644 -t '%{buildroot}%{_pkgdocdir}' -D \
9ad76d4
    CHANGES.rst \
9ad76d4
    README.rst \
a18e29f
    docs/schema.dtd \
a18e29f
    %{?with_doc_pdf:docs/_build/latex/ZConfig.pdf}
1b5ecf0
# Make a relative symlink.
1b5ecf0
ln -s '%{buildroot}%{python3_sitelib}/ZConfig/schemaless.txt' \
1b5ecf0
    '%{buildroot}%{_pkgdocdir}/schemaless.txt'
1b5ecf0
symlinks -c '%{buildroot}%{_pkgdocdir}/schemaless.txt'
ea98903
90813df
a185fb0
%check
a185fb0
%{python3} -m zope.testrunner --test-path=.
ea98903
90813df
4e77b85
%files -n python3-ZConfig -f %{pyproject_files}
4e77b85
# pyproject_files handles LICENSE.txt in dist-info, but COPYRIGHT.txt is not
4e77b85
# present there, so we manually install both files to %%{_licensedir}
90813df
%license COPYRIGHT.txt
90813df
%license LICENSE.txt
90813df
bb8ad21
# These are installed with the test extra subpackage.
266990f
%exclude %{python3_sitelib}/ZConfig/tests/
90813df
9872911
%{_bindir}/zconfig
9872911
%{_bindir}/zconfig_schema2html
6059611
%{_mandir}/man1/zconfig.1*
6059611
%{_mandir}/man1/zconfig_schema2html.1*
266990f
ea98903
bb8ad21
%files -n python3-ZConfig+test
bb8ad21
%{python3_sitelib}/ZConfig/tests/
bb8ad21
%ghost %{python3_sitelib}/*.dist-info
bb8ad21
bb8ad21
fd2f6a5
%files doc
fd2f6a5
# Depends on python3-ZConfig: separate copies of license files are not needed.
9ad76d4
%doc %{_pkgdocdir}/CHANGES.rst
fd2f6a5
%doc %{_pkgdocdir}/README.rst
9ad76d4
%doc %{_pkgdocdir}/schema.dtd
fd2f6a5
%doc %{_pkgdocdir}/schemaless.txt
fd2f6a5
%if %{with doc_pdf}
fd2f6a5
%doc %{_pkgdocdir}/ZConfig.pdf
fd2f6a5
%endif
fd2f6a5
fd2f6a5
ea98903
%changelog
63c278d
%autochangelog