Blob Blame History Raw
# Sphinx-generated HTML documentation is not suitable for packaging; see
# for discussion.
# We can generate PDF documentation as a substitute.
%bcond doc_pdf 1

Name:           python-pynamodb
Summary:        A pythonic interface to Amazon’s DynamoDB
Version:        5.5.1
Release:        %autorelease

License:        MIT
# We use the GitHub tarball instead of the PyPI tarball to get documentation
# and tests.
Source:         %{url}/archive/%{version}/PynamoDB-%{version}.tar.gz

# In setup.cfg, avoid deprecated license_file
Patch:          %{url}/pull/1207.patch

BuildArch:      noarch

BuildRequires:  python3-devel

%if %{with doc_pdf}
BuildRequires:  make
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk

%global common_description %{expand:

DynamoDB is a great NoSQL service provided by Amazon, but the API is verbose.
PynamoDB presents you with a simple, elegant API.}

%description %{common_description}

%package -n     python3-pynamodb
Summary:        %{summary}

%description -n python3-pynamodb %{common_description}

%pyproject_extras_subpkg -n python3-pynamodb signals

%package        doc
Summary:        Documentation and examples for PynamoDB

%description doc %{common_description}

%autosetup -n PynamoDB-%{version} -p1

%if %{with doc_pdf}
  # Un-pin exact versions in doc dependencies.
  # We can’t handle self-referential dependencies like .[signals]; we use the
  # -x argument to %%pyproject_buildrequires instead
  sed -r -e 's/==/>=/' -e 's/^\.\[/# &/' docs/requirements.txt
  # Get non-CI dev dependencies (no coverage/linting)
  awk '/^# only used in CI/ {ci=1}; !ci' requirements-dev.txt
} | tee requirements-filtered.txt
# Don’t generate (unfiltered) dev dependencies for tox:
sed -r -i 's/[-]rrequirements-dev\.txt//' tox.ini

%pyproject_buildrequires -x signals -t requirements-filtered.txt


%if %{with doc_pdf}
%make_build -C docs SPHINXOPTS='-j%{?_smp_build_ncpus}' latex
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'

%pyproject_save_files pynamodb


%files -n python3-pynamodb -f %{pyproject_files}
# pyproject-rpm-macros handles LICENSE; verify with “rpm -qL -p …”
%doc README.rst

%files doc
%license LICENSE
%doc README.rst
%doc examples/
%if %{with doc_pdf}
%doc docs/_build/latex/PynamoDB.pdf