Sync from SUSE:SLFO:Main python-cached-property revision 29a1b1978047efa7639156141294ccdf

This commit is contained in:
2025-05-30 17:24:30 +02:00
commit fe6ccdaccf
6 changed files with 302 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

BIN
cached-property-1.5.2.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

14
freezegun-skip.patch Normal file
View File

@@ -0,0 +1,14 @@
---
tests/test_cached_property.py | 1 +
1 file changed, 1 insertion(+)
--- a/tests/test_cached_property.py
+++ b/tests/test_cached_property.py
@@ -188,6 +188,7 @@ class TestCachedPropertyWithTTL(TestCach
self.assert_cached(check, 2)
self.assert_cached(check, 2)
+ @unittest.skip("new freezegun breaks behaviour of this test")
def test_threads_ttl_expiry(self):
Check = CheckFactory(self.cached_property_factory(ttl=100000), threadsafe=True)
check = Check()

View File

@@ -0,0 +1,88 @@
-------------------------------------------------------------------
Thu May 15 12:13:24 UTC 2025 - Markéta Machová <mmachova@suse.com>
- Convert to pip-based build
-------------------------------------------------------------------
Fri Apr 21 12:22:58 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add sle15_python_module_pythons (jsc#PED-68)
-------------------------------------------------------------------
Thu Apr 13 22:40:23 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Make calling of %{sle15modernpython} optional.
-------------------------------------------------------------------
Fri Feb 10 16:40:47 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Refresh patches and remove weird replacement of conftest.py
command in %%prep.
-------------------------------------------------------------------
Tue Jan 31 23:18:09 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add python311.patch to fix tests with 3.11
-------------------------------------------------------------------
Sat Dec 19 17:50:16 UTC 2020 - Dirk Müller <dmueller@suse.com>
- update to 1.5.2:
* Add formal support for Python 3.8
* Remove formal support for Python 3.4
* Switch from Travis to GitHub actions
* Made tests pass flake8 for Python 2.7
-------------------------------------------------------------------
Sun Aug 16 12:33:16 UTC 2020 - John Vandenberg <jayvdb@gmail.com>
- Replace nose with pytest
- Add missing Group
-------------------------------------------------------------------
Thu Mar 12 07:17:00 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
- Fix build without python2 available
-------------------------------------------------------------------
Mon Feb 25 08:43:46 UTC 2019 - John Vandenberg <jayvdb@gmail.com>
- Add HISTORY.rst to %doc
- Update to v1.5.1
* Added formal support for Python 3.7
* Removed formal support for Python 3.3
- from 1.4.3
* Catch SyntaxError from asyncio import on older versions of Python
- from 1.4.2
* Really fixed tests
- from 1.4.1
* Added conftest.py to manifest so tests work properly off the tarball
* Ensured new asyncio tests didn't break Python 2.7 builds on Debian
* Code formatting via black
- from 1.4.0
* Added asyncio support
* Remove Python 2.6 support, whose end of life was 5 years ago
- from 1.3.1
* Validate for Python 3.6
-------------------------------------------------------------------
Fri Feb 1 10:58:51 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Add patch to fix build with new freezegun (by skipping test):
* freezegun-skip.patch
-------------------------------------------------------------------
Tue Dec 4 12:46:23 UTC 2018 - Matej Cepl <mcepl@suse.com>
- Remove superfluous devel dependency for noarch package
-------------------------------------------------------------------
Sat Aug 19 08:27:48 UTC 2017 - sebix+novell.com@sebix.at
- singlespec version
-------------------------------------------------------------------
Thu Mar 17 17:38:09 UTC 2016 - jmassaguerpla@suse.com
- initial commit with version 1.3.0

View File

@@ -0,0 +1,68 @@
#
# spec file for package python-cached-property
#
# Copyright (c) 2025 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/
#
%{?sle15_python_module_pythons}
Name: python-cached-property
Version: 1.5.2
Release: 0
Summary: A decorator for caching properties in classes
License: BSD-3-Clause
Group: Development/Libraries/Python
URL: https://github.com/pydanny/cached-property
Source: https://files.pythonhosted.org/packages/source/c/cached-property/cached-property-%{version}.tar.gz
# PATCH-FIX-UPSTREAM skip test that rely on wrong freezegun behaviour
# https://github.com/pydanny/cached-property/pull/125
Patch0: freezegun-skip.patch
# PATCH-FIX-UPSTREAM Don't use asyncio.coroutine if it's not available -- https://github.com/pydanny/cached-property/pull/267
Patch1: python311.patch
BuildRequires: %{python_module freezegun}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildArch: noarch
%python_subpackages
%description
A decorator for caching properties in classes. It makes caching of time or
computational expensive properties quick and easy and it works in Python 2
and 3.
%prep
%autosetup -p1 -n cached-property-%{version}
%build
%pyproject_wheel
%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%pytest
%files %{python_files}
%license LICENSE
%doc AUTHORS.rst README.rst HISTORY.rst
%{python_sitelib}/cached[-_]property.py
%{python_sitelib}/cached[-_]property-%{version}*-info
%pycache_only %{python_sitelib}/__pycache__/cached[-_]property*
%changelog

106
python311.patch Normal file
View File

@@ -0,0 +1,106 @@
From 297031687679762849dedeaf24aa3a19116f095b Mon Sep 17 00:00:00 2001
From: Petr Viktorin <encukou@gmail.com>
Date: Thu, 2 Dec 2021 11:26:20 +0100
Subject: [PATCH 1/2] Don't use asyncio.coroutinefunction if it's not available
Python 3.11 drops the deprecated @asyncio.coroutine and
asyncio.iscoroutinefunction.
Using a wrapper with @asyncio.coroutine in __get__ wasn't
necessary (the future from asyncio.ensure_future is awaitable,
and the wrapper doesn't do anything asynchronous), so the
logic can be simplified to just call asyncio.ensure_future
(to schedule the task and store the result when it's
available).
Tests for @asyncio.coroutine are skipped on 3.11+.
An unnecessary call to asyncio.coroutine in tests is
removed: it's not necessary to call this for `async def`
functions.
---
cached_property.py | 24 +++++++++++-------------
conftest.py | 8 ++++----
tests/test_async_cached_property.py | 3 +--
3 files changed, 16 insertions(+), 19 deletions(-)
--- a/cached_property.py
+++ b/cached_property.py
@@ -13,6 +13,12 @@ try:
import asyncio
except (ImportError, SyntaxError):
asyncio = None
+if asyncio:
+ try:
+ iscoroutinefunction = asyncio.iscoroutinefunction
+ except AttributeError:
+ # Python 3.11: @asyncio.coroutine was removed
+ from inspect import iscoroutinefunction
class cached_property(object):
@@ -30,22 +36,14 @@ class cached_property(object):
if obj is None:
return self
- if asyncio and asyncio.iscoroutinefunction(self.func):
- return self._wrap_in_coroutine(obj)
+ if asyncio and iscoroutinefunction(self.func):
+ value = asyncio.ensure_future(self.func(obj))
+ else:
+ value = self.func(obj)
- value = obj.__dict__[self.func.__name__] = self.func(obj)
+ obj.__dict__[self.func.__name__] = value
return value
- def _wrap_in_coroutine(self, obj):
- @wraps(obj)
- @asyncio.coroutine
- def wrapper():
- future = asyncio.ensure_future(self.func(obj))
- obj.__dict__[self.func.__name__] = future
- return future
-
- return wrapper()
-
class threaded_cached_property(object):
"""
--- a/conftest.py
+++ b/conftest.py
@@ -1,4 +1,3 @@
-
import sys
# Whether "import asyncio" works
@@ -7,13 +6,14 @@ has_asyncio = sys.version_info[0] == 3 a
# Whether the async and await keywords work
has_async_await = sys.version_info[0] == 3 and sys.version_info[1] >= 5
+# Whether "from asyncio import coroutine" *fails*
+dropped_asyncio_coroutine = sys.version_info[0] == 3 and sys.version_info[1] >= 11
-print("conftest.py", has_asyncio, has_async_await)
-
+print("conftest.py", has_asyncio, has_async_await, dropped_asyncio_coroutine)
collect_ignore = []
-if not has_asyncio:
+if not has_asyncio or dropped_asyncio_coroutine:
collect_ignore.append("tests/test_coroutine_cached_property.py")
if not has_async_await:
--- a/tests/test_async_cached_property.py
+++ b/tests/test_async_cached_property.py
@@ -9,8 +9,7 @@ import cached_property
def unittest_run_loop(f):
def wrapper(*args, **kwargs):
- coro = asyncio.coroutine(f)
- future = coro(*args, **kwargs)
+ future = f(*args, **kwargs)
loop = asyncio.get_event_loop()
loop.run_until_complete(future)