Blob Blame History Raw
%bcond_without tests
%bcond_with hiro

# Sphinx-generated HTML documentation is not suitable for packaging; see
# for discussion.
# We can generate PDF documentation as a substitute.
%bcond_without doc_pdf

%if 0%{?fc36}
# python3dist(redis) is too old
%bcond_with redis
%bcond_without redis
# Missing python3dist(coredis), python3dist(coredis[hiredis])
%bcond_with async_redis
# Missing python3dist(emcache)
%bcond_with async_memcached
# Missing python3dist(motor)
%bcond_with async_mongodb

%global pypi_name limits

%global _description %{expand:
This package is a python library to perform rate
limiting with commonly used storage backends
(Redis, Memcached & MongoDB).}

Name:           python-%{pypi_name}
Version:        2.8.0
Release:        2%{?dist}
Summary:        Utilities to implement rate limiting using various strategies

License:        MIT
URL:  {pypi_name}
Source0:        %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz

BuildArch:      noarch

%description %_description

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

BuildRequires:  python3-devel
%if %{without redis}
# Even though redis is too old for the redis extra, we still need it for
# test_lazy_dependency_found and test_lazy_dependency_version_low.
BuildRequires:  python3dist(redis)

%description -n python3-%{pypi_name} %_description

%package doc
Summary:        %{summary}

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

%description doc
Documentation for %{name}.

%if %{with async_redis} && %{with async_memcached} && %{with async_mongodb} && %{with redis}
%pyproject_extras_subpkg -n python3-%{pypi_name} all
%if %{with async_redis}
%pyproject_extras_subpkg -n python3-%{pypi_name} async-redis
%if %{with async_memcached}
%pyproject_extras_subpkg -n python3-%{pypi_name} async-memcached
%if %{with async_mongodb}
%pyproject_extras_subpkg -n python3-%{pypi_name} async-mongodb
%if %{with redis}
%pyproject_extras_subpkg -n python3-%{pypi_name} redis rediscluster
%pyproject_extras_subpkg -n python3-%{pypi_name} memcached mongodb

%autosetup -n %{pypi_name}-%{version}
rm -fv poetry.lock
# We only need to generate the *additional* requirements for testing.  Also, we
# should patch out linting and coverage dependencies
# (
sed -r -e '/^[[:blank:]]*(-r|coverage|pytest-cov|lovely-pytest-docker)\b/d' \
    requirements/test.txt | tee requirements/test-filtered.txt
sed -r -i '/^[[:blank:]]*(--cov|-K)\b/d' pytest.ini
%if %{without hiro}
sed -r -i '/^[[:blank:]]*(hiro)/d' requirements/test-filtered.txt
%if %{without redis}
# If we don’t have a new enough redis, we won’t need the extra fixtures for it:
sed -r -i 's/^import redis/# &/' tests/
# Allow newer versions of doc dependencies.
# Drop unused “furo” HTML theme.
# Missing dependencies (but we can build documentation anyway):
# - python3dist(sphinx-paramlinks)
sed -r -e 's/==/>=/' \
    -e '/^[[:blank:]]*(furo|sphinx-paramlinks)/d' \
    requirements/docs.txt |
%if 0%{?fc36}
    # Tolerate Sphinx 4 in addition to the Sphinx 5 desired by upstream.
    sed -r -e 's/(Sphinx[>=]=)5/\14/' |
%if 0%{?fc36} || 0%{?fc37}
    # Tolerate versions of sphinxext-opengraph older than upstream wants
    sed -r -e 's/(sphinxext-opengraph)([>=]=.*)/\1/' |
  tee requirements/docs-filtered.txt
sed -r -i '/(paramlinks)/d' doc/source/
# Cannot use remote intersphinx inventories in offline build:
echo 'intersphinx_mapping.clear()' >> doc/source/

# Relax packaging version constraint
sed -i 's/packaging>=21,<23/packaging>=21,<24/' requirements/main.txt

%if %{with async_redis} && %{with async_memcached} && %{with async_mongodb} && %{with redis}
%pyproject_buildrequires -x all %{?with_tests:requirements/test-filtered.txt}
%{pyproject_buildrequires \
  %{?with_tests:requirements/test-filtered.txt} \
  %{?with_doc_pdf:requirements/docs-filtered.txt} \
  %{?with_async_redis:-x async-redis} \
  %{?with_async_memcached:-x async-memcached} \
  %{?with_async_mongodb:-x async-mongodb} \
  %{?with_redis:-x redis -x rediscluster} \
  -x memcached \
  -x mongodb}


%if %{with doc_pdf}
%make_build -C doc latex SPHINXOPTS='%{?_smp_mflags}'
%make_build -C doc/build/latex LATEXMKOPTS='-quiet'

%pyproject_save_files limits

%if %{with tests}
%if %{without hiro}
ignore="${ignore-} --ignore=tests/storage/"
ignore="${ignore-} --ignore=tests/aio/storage/"
%if %{without redis}
# We cannot import these at all:
ignore="${ignore-} --ignore=tests/storage/"
ignore="${ignore-} --ignore=tests/storage/"
ignore="${ignore-} --ignore=tests/storage/"
# The deselected tests generally require various servers and/or Docker.
m='not integration'
m="${m-}${m+ and }not redis"
m="${m-}${m+ and }not redis_sentinel"
m="${m-}${m+ and }not redis_cluster"
m="${m-}${m+ and }not mongodb"
m="${m-}${m+ and }not memcached"
%pytest ${ignore-} -m "${m-}"
# Since quite a few upstream tests needed to be deselected, run the import
# “smoke tests” too.

%files -n python3-%{pypi_name} -f %{pyproject_files}
%doc README.rst

%files doc
%license LICENSE.txt
%if %{with doc_pdf}
%doc doc/build/latex/%{pypi_name}.pdf

* Fri Jan 20 2023 Tomáš Hrnčiar <> - 2.8.0-2
- Relax packaging version constraint

* Tue Dec 27 2022 Benjamin A. Beasley <> - 2.8.0-1
- Drop F35 conditionals
- Update to 2.8.0 (close RHBZ#2152428)

* Sun Oct 23 2022 Benjamin A. Beasley <> - 2.7.1-1
- Update to 2.7.1 (close RHBZ#2136594)

* Sun Oct 09 2022 Benjamin A. Beasley <> - 2.7.0-1
- Support F36 and F35 (close RHBZ#2133279)
- Don’t loosen Sphinx version bound on releases where we don’t have to do so
- Update to 2.7.0 (close RHBZ#2107863)

* Fri Jul 22 2022 Fedora Release Engineering <> - 2.6.3-2
- Rebuilt for

* Fri Jul 08 2022 Benjamin A. Beasley <> - 2.6.3-1
- Update to 2.6.3 (
- Restore sphinxext-opengraph doc dependency; it is now packaged
- Backport upstream support for Sphinx 5 (fix RHBZ#2105292)

* Tue Jun 14 2022 Python Maint <> - 2.6.2-2
- Rebuilt for Python 3.11

* Tue May 24 2022 Benjamin A. Beasley <> - 2.6.2-1
- Update to 2.6.2
- Add extras metapackages where dependencies are available
- Use more generated BuildRequires
- Enable some tests
- Build the PDF documentation

* Wed May 11 2022 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 2.6.1-1
- Initial package