public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-python/cached-property/files/, dev-python/cached-property/
@ 2020-08-17 18:55 David Seifert
  0 siblings, 0 replies; 2+ messages in thread
From: David Seifert @ 2020-08-17 18:55 UTC (permalink / raw
  To: gentoo-commits

commit:     7b4d8767a9e1190ac84c8a44c018d0c8ea7772ac
Author:     David Seifert <soap <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 17 18:54:40 2020 +0000
Commit:     David Seifert <soap <AT> gentoo <DOT> org>
CommitDate: Mon Aug 17 18:54:40 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7b4d8767

dev-python/cached-property: Add python 3.9

* Mask problematic 'test_threads_ttl_expiry' test fails
  with high core count:
    https://github.com/pydanny/cached-property/issues/24

Bug: https://bugs.gentoo.org/638250
Package-Manager: Portage-3.0.3, Repoman-3.0.0
Signed-off-by: David Seifert <soap <AT> gentoo.org>

 .../cached-property/cached-property-1.5.1.ebuild   | 22 +++++++++++++---------
 .../files/cached-property-1.5.1-test-failure.patch | 10 ++++++++++
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/dev-python/cached-property/cached-property-1.5.1.ebuild b/dev-python/cached-property/cached-property-1.5.1.ebuild
index 01da4c80d70..04b4c981768 100644
--- a/dev-python/cached-property/cached-property-1.5.1.ebuild
+++ b/dev-python/cached-property/cached-property-1.5.1.ebuild
@@ -1,8 +1,9 @@
 # Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=6
-PYTHON_COMPAT=( python{3_6,3_7,3_8} )
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6..9} )
 
 inherit distutils-r1
 
@@ -14,15 +15,18 @@ LICENSE="BSD"
 SLOT="0"
 KEYWORDS="amd64 ppc64 x86"
 
-DEPEND="
-	test? (
-		dev-python/freezegun[${PYTHON_USEDEP}]
-	)"
-RDEPEND=""
+DEPEND="test? ( dev-python/freezegun[${PYTHON_USEDEP}] )"
 
 distutils_enable_tests pytest
 
-src_install() {
-	distutils-r1_src_install
+python_prepare_all() {
+	# bug 638250
+	eapply "${FILESDIR}"/${PN}-1.5.1-test-failure.patch
+
+	distutils-r1_python_prepare_all
+}
+
+python_install_all() {
 	dodoc README.rst HISTORY.rst CONTRIBUTING.rst AUTHORS.rst
+	distutils-r1_python_install_all
 }

diff --git a/dev-python/cached-property/files/cached-property-1.5.1-test-failure.patch b/dev-python/cached-property/files/cached-property-1.5.1-test-failure.patch
new file mode 100644
index 00000000000..03fabd2900c
--- /dev/null
+++ b/dev-python/cached-property/files/cached-property-1.5.1-test-failure.patch
@@ -0,0 +1,10 @@
+--- a/tests/test_cached_property.py
++++ b/tests/test_cached_property.py
+@@ -191,6 +191,7 @@
+         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()


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-python/cached-property/files/, dev-python/cached-property/
@ 2022-05-18 14:22 Andrew Ammerlaan
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Ammerlaan @ 2022-05-18 14:22 UTC (permalink / raw
  To: gentoo-commits

commit:     768757d3bf88df981cae7b117bbe97177bba8945
Author:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
AuthorDate: Wed May 18 11:31:03 2022 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
CommitDate: Wed May 18 14:22:34 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=768757d3

dev-python/cached-property: update EAPI 7 -> 8, patch for py3.11

Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>

 .../cached-property-1.5.2-r1.ebuild                |  30 +++++
 .../files/cached-property-1.5.2-python311.patch    | 142 +++++++++++++++++++++
 2 files changed, 172 insertions(+)

diff --git a/dev-python/cached-property/cached-property-1.5.2-r1.ebuild b/dev-python/cached-property/cached-property-1.5.2-r1.ebuild
new file mode 100644
index 000000000000..9da94d1177a4
--- /dev/null
+++ b/dev-python/cached-property/cached-property-1.5.2-r1.ebuild
@@ -0,0 +1,30 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{8..11} pypy3 )
+DISTUTILS_USE_PEP517=setuptools
+
+inherit distutils-r1
+
+DESCRIPTION="A cached-property for decorating methods in classes"
+HOMEPAGE="https://github.com/pydanny/cached-property"
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86"
+
+BDEPEND="test? ( dev-python/freezegun[${PYTHON_USEDEP}] )"
+
+distutils_enable_tests pytest
+
+DOCS=( README.rst HISTORY.rst CONTRIBUTING.rst AUTHORS.rst )
+
+PATCHES=(
+	# bug 638250
+	"${FILESDIR}"/${PN}-1.5.1-test-failure.patch
+	# @asyncio.coroutine removed in py3.11
+	"${FILESDIR}"/${PN}-1.5.2-python311.patch
+)

diff --git a/dev-python/cached-property/files/cached-property-1.5.2-python311.patch b/dev-python/cached-property/files/cached-property-1.5.2-python311.patch
new file mode 100644
index 000000000000..989033f20036
--- /dev/null
+++ b/dev-python/cached-property/files/cached-property-1.5.2-python311.patch
@@ -0,0 +1,142 @@
+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                         |  6 +++++-
+ tests/test_async_cached_property.py |  3 +--
+ 3 files changed, 17 insertions(+), 16 deletions(-)
+
+diff --git a/cached_property.py b/cached_property.py
+index 3135871..254739c 100644
+--- a/cached_property.py
++++ b/cached_property.py
+@@ -13,6 +13,12 @@
+     import asyncio
+ except (ImportError, SyntaxError):
+     asyncio = None
++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 @@ def __get__(self, obj, cls):
+         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):
+     """
+diff --git a/conftest.py b/conftest.py
+index 0563f64..1c4b618 100644
+--- a/conftest.py
++++ b/conftest.py
+@@ -7,13 +7,17 @@
+ # 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*
++version_info = sys.version_info
++dropped_asyncio_coroutine = version_info[0] == 3 and version_info[1] >= 11
++
+ 
+ print("conftest.py", has_asyncio, has_async_await)
+ 
+ 
+ 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:
+diff --git a/tests/test_async_cached_property.py b/tests/test_async_cached_property.py
+index 4ba84f3..d61cc28 100644
+--- a/tests/test_async_cached_property.py
++++ b/tests/test_async_cached_property.py
+@@ -9,8 +9,7 @@
+ 
+ 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)
+ 
+
+From 9b210d12fa73c91743378ba4a966417846e7ea9a Mon Sep 17 00:00:00 2001
+From: Petr Viktorin <encukou@gmail.com>
+Date: Thu, 2 Dec 2021 11:44:18 +0100
+Subject: [PATCH 2/2] Restore	compatibility with python 2.7
+
+This is	still necessary	according to the Contributing Guidelines.
+---
+ cached_property.py | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/cached_property.py b/cached_property.py
+index 254739c..944e2f5 100644
+--- a/cached_property.py
++++ b/cached_property.py
+@@ -13,12 +13,12 @@
+     import asyncio
+ except (ImportError, SyntaxError):
+     asyncio = None
+-try:
+-    iscoroutinefunction = asyncio.iscoroutinefunction
+-except AttributeError:
+-    # Python 3.11: @asyncio.coroutine was removed
+-    from inspect import iscoroutinefunction
+-
++if asyncio:
++    try:
++        iscoroutinefunction = asyncio.iscoroutinefunction
++    except AttributeError:
++        # Python 3.11: @asyncio.coroutine was removed
++        from inspect import iscoroutinefunction
+ 
+ 
+ class cached_property(object):


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-18 14:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-18 14:22 [gentoo-commits] repo/gentoo:master commit in: dev-python/cached-property/files/, dev-python/cached-property/ Andrew Ammerlaan
  -- strict thread matches above, loose matches on Subject: below --
2020-08-17 18:55 David Seifert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox