%global pypi_name django-cacheops
%global _empty_manifest_terminate_build 0
Name:		python-%{pypi_name}
Version:	7.2
Release:	1
Summary:	A slick ORM cache with automatic granular event-driven invalidation for Django.
License:	BSD
URL:		http://github.com/Suor/django-cacheops
Source0:	https://files.pythonhosted.org/packages/1b/92/9df8a60ee959c214705ec3d3ccf80820097672a0260b149cf2751e818086/django_cacheops-%{version}.tar.gz
BuildArch:	noarch

%description
A slick ORM cache with automatic granular event-driven invalidation.

%package -n python3-django-cacheops
Summary:	A slick ORM cache with automatic granular event-driven invalidation for Django.
Provides:	python-django-cacheops = %{version}-%{release}
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
%description -n python3-django-cacheops
A slick ORM cache with automatic granular event-driven invalidation.

%package help
Summary:	Development documents and examples for django-cacheops
Provides:	python3-django-cacheops-doc
%description help
A slick ORM cache with automatic granular event-driven invalidation.

%prep
%autosetup -n django_cacheops-%{version}

%build
%py3_build

%install
%py3_install
# Remove __pycache__ directories (not needed in package, Python will regenerate them at runtime)
find %{buildroot} -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find %{buildroot} -name "*.pyc" -delete 2>/dev/null || true
find %{buildroot} -name "*.pyo" -delete 2>/dev/null || true
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
if [ -f README.rst ]; then cp -af README.rst %{buildroot}/%{_pkgdocdir}; fi
if [ -f README.md ]; then cp -af README.md %{buildroot}/%{_pkgdocdir}; fi
if [ -f README.txt ]; then cp -af README.txt %{buildroot}/%{_pkgdocdir}; fi
# Remove __pycache__ directories before generating filelist
find %{buildroot} -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find %{buildroot} -name "*.pyc" -delete 2>/dev/null || true
find %{buildroot} -name "*.pyo" -delete 2>/dev/null || true
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f ! -path "*/__pycache__/*" -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f ! -path "*/__pycache__/*" -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f ! -path "*/__pycache__/*" -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f ! -path "*/__pycache__/*" -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
# Final cleanup of __pycache__ before RPM checks for unpackaged files
rm -rf %{buildroot}%{python3_sitelib}/cacheops/__pycache__ 2>/dev/null || true
rm -rf %{buildroot}%{python3_sitelib}/cacheops/*/__pycache__ 2>/dev/null || true
rm -rf %{buildroot}%{python3_sitelib}/cacheops/*/*/__pycache__ 2>/dev/null || true
find %{buildroot} -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find %{buildroot} -name "*.pyc" -delete 2>/dev/null || true
find %{buildroot} -name "*.pyo" -delete 2>/dev/null || true

%files -n python3-django-cacheops -f filelist.lst
%dir %{python3_sitelib}/*
%exclude %{python3_sitelib}/cacheops/__pycache__
%exclude %{python3_sitelib}/cacheops/__pycache__/*
%exclude %{python3_sitelib}/cacheops/*/__pycache__
%exclude %{python3_sitelib}/cacheops/*/__pycache__/*
%exclude %{python3_sitelib}/cacheops/*/*/__pycache__
%exclude %{python3_sitelib}/cacheops/*/*/__pycache__/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Wed Nov 12 2025 <zhaojianbin@kylinos.com> - 7.2-1
- Update version to 7.2
- Fix spec file format: add pypi_name variable, use variables in Name and Source0
- Remove __pycache__ directories from package (Python will regenerate them at runtime)
- Add %exclude in %files section to explicitly exclude __pycache__ directories (including nested directories like cacheops/management/commands)

* Sun Dec 22 2024 sqfu <dev01203@linx-info.com> - 7.1-1
- Upgrade package to version 7.1
- support and test against Python 3.12 and Django 5.0
- prevent dups in conjs and disjs by using proper data-structures (thx Sergey Prokopiev for a test)
- unpin funcy major version
- fixed conj keys TTL in Redis 7.x
- updated and cleaned up tests

* Thu Nov 30 2023 jiangxinyu <jiangxinyu@kylinos.cn> - 7.0.2-1
- Upgrade package to version 7.0.2

* Fri Jul 07 2023 zhangchenglin <zhangchenglin@kylinos.cn> - 7.0.1-1
- Update package to version 7.0.1

* Thu Mar 16 2023 wubijie <wubijie@kylinos.cn> - 7.0-1
- Update package to version 7.0

* Thu Mar 2 2023 wubijie <wubijie@kylinos.cn> - 6.2-1
- Update package to version 6.2

* Thu Sep 29 2022 jiangxinyu <jiangxinyu@kylinos.cn> - 6.1-1
- Upgrade to 6.1

* Thu Apr 21 2022 liqiuyu <liqiuyu@kylinos.cn> - 6.0-2
- Add zlib to buildrequires 

* Mon Dec 06 2021 Python_Bot <Python_Bot@openeuler.org> -6.0-1
- Package Init