Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
7e22dab7eb
!8 Fix test failure due to python 3.11
From: @cherry530 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
2023-07-22 10:54:20 +00:00
cherry530
b1d50a5bc4 Fix test failure
Signed-off-by: cherry530 <707078654@qq.com>
2023-07-22 18:05:25 +08:00
openeuler-ci-bot
5a19cd48fd
!6 License compliance rectification
From: @lauk001 
Reviewed-by: @shinwell_hu 
Signed-off-by: @shinwell_hu
2022-06-20 01:51:23 +00:00
lauk001
66d4d3a6e4 License compliance rectification 2022-06-17 14:30:21 +08:00
openeuler-ci-bot
434a797ac3
!5 Upgrade to 1.5.2
From: @houyingchao 
Reviewed-by: @myeuler 
Signed-off-by: @myeuler
2022-06-14 09:07:04 +00:00
houyingchao
64e45bfd24 Upgrade to 1.5.2 2022-06-14 16:51:52 +08:00
openeuler-ci-bot
1ea92682b3 !4 解决软件包python-cached_property在mainline的编译失败问题
From: @tushenmei
Reviewed-by: @myeuler
Signed-off-by: @myeuler
2021-08-06 09:27:41 +00:00
tushenmei
9a291db0ee cached-property-1.5.1-test-failure 2021-08-05 20:46:37 +08:00
openeuler-ci-bot
b5b2591878 !3 Remove subpackage python2-cached_property
From: @lei_ju
Reviewed-by: @small_leek
Signed-off-by: @small_leek
2020-10-30 15:39:52 +08:00
lei_ju
6e5a680aa4 Remove subpackage python2-cached_property 2020-10-30 14:24:59 +08:00
5 changed files with 139 additions and 54 deletions

View File

@ -0,0 +1,13 @@
diff -Nur cached-property-1.5.1/tests/test_cached_property.py cached-property-1.5.1-new/tests/test_cached_property.py
--- cached-property-1.5.1/tests/test_cached_property.py 2018-09-05 23:30:37.000000000 +0800
+++ cached-property-1.5.1-new/tests/test_cached_property.py 2021-08-05 20:11:27.000000000 +0800
@@ -190,7 +190,8 @@
# Things are not reverted when we are back to the present
self.assert_cached(check, 2)
self.assert_cached(check, 2)
-
+
+ @unittest.skip("Gentoo Bug #638250")
def test_threads_ttl_expiry(self):
Check = CheckFactory(self.cached_property_factory(ttl=100000), threadsafe=True)
check = Check()

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,105 @@
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)

View File

@ -1,47 +1,28 @@
%bcond_with python2
%global py2dir %{_builddir}/python2-%{name}-%{version}-%{release}
Name: python-cached_property Name: python-cached_property
Version: 1.5.1 Version: 1.5.2
Release: 1 Release: 3
Summary: A cached-property for decorating methods in Python classes Summary: A cached-property for decorating methods in Python classes
License: BSD License: BSD-3-Clause
URL: https://github.com/pydanny/cached-property URL: https://github.com/pydanny/cached-property
Source0: https://github.com/pydanny/cached-property/archive/%{version}/cached-property-%{version}.tar.gz Source0: https://github.com/pydanny/cached-property/archive/%{version}/cached-property-%{version}.tar.gz
Patch0001: cached-property-1.5.1-test-failure.patch
Patch0002: fix-test-failure-due-to-python3.11.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-devel python%{python3_pkgversion}-dateutil BuildRequires: python%{python3_pkgversion}-devel python%{python3_pkgversion}-dateutil
BuildRequires: python%{python3_pkgversion}-freezegun python%{python3_pkgversion}-pytest BuildRequires: python%{python3_pkgversion}-freezegun python%{python3_pkgversion}-pytest
%if %{with python2}
BuildRequires: python2-devel python2-dateutil python2-freezegun python2-pytest
%endif
%description %description
cached_property allows properties in Python classes to be cached until the cache cached_property allows properties in Python classes to be cached until the cache
is invalidated or expired. is invalidated or expired.
%if %{with python2}
%package -n python2-cached_property
Summary: A cached-property for decorating methods in Python classes.
%{?python_provide:%python_provide python2-cached_property}
Provides: python2-cached-property = %{version}-%{release}
Obsoletes: python2-cached-property < 1.3.0-2
%description -n python2-cached_property
cached_property allows properties in Python classes to be cached until the cache
is invalidated or expired.
%endif
%package -n python%{python3_pkgversion}-cached_property %package -n python%{python3_pkgversion}-cached_property
Summary: A cached-property for decorating methods in Python classes. Summary: A cached-property for decorating methods in Python classes.
%{?python_provide:%python_provide python%{python3_pkgversion}-cached_property} %{?python_provide:%python_provide python%{python3_pkgversion}-cached_property}
Provides: python%{python3_pkgversion}-cached-property = %{version}-%{release} Provides: python%{python3_pkgversion}-cached-property = %{version}-%{release}
Obsoletes: python%{python3_pkgversion}-cached-property < 1.3.0-2 Obsoletes: python%{python3_pkgversion}-cached-property < 1.3.0-2
%if ! %{with python2}
Obsoletes: python2-cached_property < %{version}-%{release}
%endif
%description -n python%{python3_pkgversion}-cached_property %description -n python%{python3_pkgversion}-cached_property
cached_property allows properties in Python classes to be cached until the cache cached_property allows properties in Python classes to be cached until the cache
@ -52,44 +33,15 @@ is invalidated or expired.
%prep %prep
%autosetup -n cached-property-%{version} -p1 %autosetup -n cached-property-%{version} -p1
%if %{with python2}
rm -rf %{py2dir}
cp -a . %{py2dir}
%endif
%build %build
%{__python3} setup.py build %{__python3} setup.py build
%if %{with python2}
pushd %{py2dir}
%{__python2} setup.py build
popd
%endif
%install %install
%{__python3} setup.py install -O1 --skip-build --root %{buildroot} %{__python3} setup.py install -O1 --skip-build --root %{buildroot}
%if %{with python2}
pushd %{py2dir}
%{__python2} setup.py install -O1 --skip-build --root %{buildroot}
popd
%endif
%check %check
PYTHONPATH=./ py.test-3 PYTHONPATH=./ py.test-3
%if %{with python2}
PYTHONPATH=./ py.test-2
%endif
%if %{with python2}
%files -n python2-cached_property
%defattr(-,root,root)
%doc AUTHORS.rst
%license LICENSE
%{python2_sitelib}/cached_property*
%endif
%files -n python%{python3_pkgversion}-cached_property %files -n python%{python3_pkgversion}-cached_property
%defattr(-,root,root) %defattr(-,root,root)
%doc AUTHORS.rst %doc AUTHORS.rst
@ -102,5 +54,20 @@ PYTHONPATH=./ py.test-2
%doc HISTORY.rst CONTRIBUTING.rst README.rst %doc HISTORY.rst CONTRIBUTING.rst README.rst
%changelog %changelog
* Sat Jul 22 2023 xu_ping <707078654@qq.com> - 1.5.2-3
- Fix test failure due to python 3.11
* Fri Jun 17 2022 liukuo <liukuo@kylinos.cn> - 1.5.2-2
- License compliance rectification
* Tue Jun 14 2022 houyingchao <houyingchao@h-partners.com> - 1.5.2-1
- Upgrade to 1.5.2
* Thu Aug 5 2021 Shenmei Tu <tushenmei@huawei.com> - 1.5.1-3
- cached-property-1.5.1-test-failure.patch
* Wed Oct 21 2020 chengzihan <chengzihan2@huawei.com> - 1.5.1-2
- Remove subpackage python2-cached_property
* Wed Feb 12 2020 openEuler Buildteam <buildteam@openeuler.org> - 1.5.1-1 * Wed Feb 12 2020 openEuler Buildteam <buildteam@openeuler.org> - 1.5.1-1
- Package init - Package init