18c8f7b
# Sphinx-generated HTML documentation is not suitable for packaging; see
18c8f7b
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
18c8f7b
#
18c8f7b
# We can generate PDF documentation as a substitute.
4aa7369
%bcond doc_pdf 1
18c8f7b
18c8f7b
Name:           python-pynamodb
18c8f7b
Summary:        A pythonic interface to Amazon’s DynamoDB
14b13d1
Version:        6.0.0
18c8f7b
Release:        %autorelease
18c8f7b
ccbde28
# SPDX
18c8f7b
License:        MIT
18c8f7b
URL:            https://github.com/pynamodb/PynamoDB
18c8f7b
# We use the GitHub tarball instead of the PyPI tarball to get documentation
18c8f7b
# and tests.
83b2ece
Source:         %{url}/archive/%{version}/PynamoDB-%{version}.tar.gz
18c8f7b
18c8f7b
BuildArch:      noarch
18c8f7b
18c8f7b
BuildRequires:  python3-devel
18c8f7b
18c8f7b
%if %{with doc_pdf}
18c8f7b
BuildRequires:  make
18c8f7b
BuildRequires:  python3-sphinx-latex
18c8f7b
BuildRequires:  latexmk
18c8f7b
%endif
18c8f7b
18c8f7b
%global common_description %{expand:
18c8f7b
%{summary}.
18c8f7b
18c8f7b
DynamoDB is a great NoSQL service provided by Amazon, but the API is verbose.
18c8f7b
PynamoDB presents you with a simple, elegant API.}
18c8f7b
18c8f7b
%description %{common_description}
18c8f7b
18c8f7b
18c8f7b
%package -n     python3-pynamodb
18c8f7b
Summary:        %{summary}
18c8f7b
18c8f7b
%description -n python3-pynamodb %{common_description}
18c8f7b
18c8f7b
18c8f7b
%pyproject_extras_subpkg -n python3-pynamodb signals
18c8f7b
18c8f7b
18c8f7b
%package        doc
18c8f7b
Summary:        Documentation and examples for PynamoDB
18c8f7b
18c8f7b
%description doc %{common_description}
18c8f7b
18c8f7b
18c8f7b
%prep
3e37d25
%autosetup -n PynamoDB-%{version} -p1
18c8f7b
18c8f7b
{
18c8f7b
%if %{with doc_pdf}
124e2ba
  # Un-pin exact versions in doc dependencies.
124e2ba
  #
124e2ba
  # We can’t handle self-referential dependencies like .[signals]; we use the
124e2ba
  # -x argument to %%pyproject_buildrequires instead
124e2ba
  sed -r -e 's/==/>=/' -e 's/^\.\[/# &/' docs/requirements.txt
18c8f7b
%endif
18c8f7b
  # Get non-CI dev dependencies (no coverage/linting)
18c8f7b
  awk '/^# only used in CI/ {ci=1}; !ci' requirements-dev.txt
5bc7539
} | tee requirements-filtered.txt
18c8f7b
18c8f7b
18c8f7b
%generate_buildrequires
14b13d1
%pyproject_buildrequires -x signals requirements-filtered.txt
18c8f7b
18c8f7b
18c8f7b
%build
18c8f7b
%pyproject_wheel
18c8f7b
18c8f7b
%if %{with doc_pdf}
d35af4f
%make_build -C docs SPHINXOPTS='-j%{?_smp_build_ncpus}' latex
18c8f7b
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
18c8f7b
%endif
18c8f7b
18c8f7b
18c8f7b
%install
18c8f7b
%pyproject_install
93fcadc
%pyproject_save_files -l pynamodb
18c8f7b
18c8f7b
18c8f7b
%check
14b13d1
# The integration tests need to connect to a local copy of DynamoDB; see the
14b13d1
# “Run dynamodb_local” step in .github/workflows.test.yaml. We can’t use a
14b13d1
# pre-compiled Java application for testing, and only a negligible number of
14b13d1
# integration tests can work without it, so we skip the integration tests.
14b13d1
%pytest --ignore-glob='tests/integration/*' -v
18c8f7b
18c8f7b
18c8f7b
%files -n python3-pynamodb -f %{pyproject_files}
18c8f7b
%doc README.rst
18c8f7b
18c8f7b
18c8f7b
%files doc
18c8f7b
%license LICENSE
18c8f7b
%doc README.rst
4c31171
%doc examples/
18c8f7b
%if %{with doc_pdf}
18c8f7b
%doc docs/_build/latex/PynamoDB.pdf
18c8f7b
%endif
18c8f7b
18c8f7b
18c8f7b
%changelog
18c8f7b
%autochangelog