#
# spec file for package python-diskcache
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%if 0%{?suse_version} == 1600
# No django in SLFO:Main
%bcond_with django
%else
%bcond_with django
%endif

%{?sle15_python_module_pythons}
Name:           python-diskcache
Version:        5.6.3
Release:        3.4
Summary:        Disk and file backed cache
License:        Apache-2.0
URL:            https://grantjenks.com/docs/diskcache/
Source:         https://github.com/grantjenks/python-diskcache/archive/v%{version}.tar.gz#/diskcache-%{version}.tar.gz
BuildRequires:  %{python_module pytest-xdist}
BuildRequires:  %{python_module pytest}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{pythons}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
%if %{with django}
BuildRequires:  %{python_module Django if (%python-base without python36-base)}
BuildRequires:  %{python_module pytest-django if (%python-base without python36-base)}
%endif
Requires:       python
BuildArch:      noarch
%python_subpackages

%description
DiskCache: Disk Backed Cache

DiskCache is a disk and file backed cache library, written
in pure Python, and compatible with Django.

%prep
%setup -q
sed -i '/--cov/d' tox.ini

%build
%python_build

%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%check
%if %{without django}
python_flags=("--ignore" "tests/test_doctest.py" "-k" "not README.rst")
%else
# No python36-Django 4 on TW
python36_flags=("--ignore" "tests/test_doctest.py" "-k" "not README.rst")
%endif
# Broken since Django 3.2 -- https://github.com/grantjenks/python-diskcache/issues/210
donttest_djangocache="--ignore tests/test_djangocache.py"
%pytest "${$python_flags[@]}" "${python_flags[@]}" ${donttest_djangocache}

%files %{python_files}
%license LICENSE
%doc README.rst
%{python_sitelib}/diskcache
%{python_sitelib}/diskcache-%{version}*-info

%changelog
* Tue Oct  1 2024 Daniel Garcia <daniel.garcia@suse.com>
- Make Django build-requirement conditional and disable by default for
  SUSE:SLFO:Main, bsc#1231124
* Wed Sep 27 2023 ecsos <ecsos@opensuse.org>
- Add %%{?sle15_python_module_pythons}
* Mon Sep  4 2023 Dirk Müller <dmueller@suse.com>
- update to 5.6.3:
  * Fix peek when value is so large that a file is used
* Wed Apr 26 2023 Dirk Müller <dmueller@suse.com>
- update to 5.6.1
  * Close the cache explictly before deleting the reference
  * pylint fixes
  * Add maxlen parameter to diskcache.Deque
  * update docs
  * Support pathlib.Path as directory argument
* Sat Jan 15 2022 Dirk Müller <dmueller@suse.com>
- update to 5.4.0:
  * test django 3.2
  * Fix DjangoCache.delete to return True/False
  * remove unused imports
  * run isort
* Mon Dec 27 2021 Ben Greiner <code@bnavigator.de>
- Update to 5.3.0
  * Support for Python 3.10 in testing (#238)
  * Add support for Python 3.10
  * Update copyright to 2022
  * Bump version to 5.3.0
  * Add Python 3.10 to the README
- Avoid django test collections errors on python 3.6:#
  no python36-Django 4
- Keep ignoring djangocache tests due to
  gh#grantjenks/python-diskcache#210
* Tue Nov 17 2020 Steve Kowalik <steven.kowalik@suse.com>
- Update to 5.1.0:
  * Support transactions in FanoutCache (probably a bad idea)
  * Prevent cache shard attribute access when unsafe
* Thu Sep 17 2020 Dirk Mueller <dmueller@suse.com>
- update to 5.0.3:
  * drop python 2.7 support
  * python 3.8 fixes
  * add documentation about cache volume caveats
* Thu Feb 27 2020 Steve Kowalik <steven.kowalik@suse.com>
- Update to 4.1.0:
  * Move zero-expiration logic into memoize (rather than Cache.set)
  * Provide JSONDisk with diskcache (#124)
  * Add check for DEFAULT_TIMEOUT in DjangoCache.memoize
* Thu Nov 14 2019 Tomáš Chvátal <tchvatal@suse.com>
- Update to pull in full python due to the dependencies
* Thu Jul 25 2019 pgajdos@suse.com
- version update to 4.0.0
  * no upstream changelog
* Fri Mar  8 2019 Tomáš Chvátal <tchvatal@suse.com>
- Update to 3.1.1:
  * Fix various timeouts
  * Small fixes around
* Sun Jun 10 2018 jengelh@inai.de
- Remove metadata redundancies from description.
* Fri Jun  8 2018 petr@cervinka.net
- Initial package version
- Django related tests are excluded from python3 tests. Tests are made for Django1
  only. Django1 is for python2 only in distribution.