From patchwork Fri Apr 4 19:16:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 41278 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 4275027BBEA; Fri, 4 Apr 2025 20:18:50 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 713BA27BBE2 for ; Fri, 4 Apr 2025 20:18:49 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u0mYP-0006iH-AC; Fri, 04 Apr 2025 15:18:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u0mYL-0006ch-0c for guix-patches@gnu.org; Fri, 04 Apr 2025 15:18:09 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u0mYK-0007p4-MA for guix-patches@gnu.org; Fri, 04 Apr 2025 15:18:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=Bt14lIzipCMSo+u1yb6zqxKsjqnovthSam03fUgNxsw=; b=b5bF/cvdrgesYY7v5eDo/GrTwG8QXz4uHqceVcwelMjKj786E1Ej6WHtTEP2Z6ewCh1SnoxnIlMUpKGOflfrXEVL5uGgcXoonQlGgmHvKu5HoeSahd0m+d+QTvUKazTo0SN8JxW4nSY4WTkPjSCJzQL1EZNYHF8h2/XSghTWURWPqwaXoluy1ccnaHcobbvkWYOfrHydwrC0cyeZGmGY1DFuVPvh19sD9k/qod+ail/0tFBnVvKAp2neuuhNyQOc2vue83fkysD3DxZOjeGr3W9Oduov4n6nTc0NO6opg1K5QwpYhDBOvxcElhwtKv1KJAqARK31+871AQZKCNdagw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u0mYK-0007La-6Y for guix-patches@gnu.org; Fri, 04 Apr 2025 15:18:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77541] [PATCH 11/38] gnu: python-property-cached: Fix build. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 04 Apr 2025 19:18:08 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77541 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77541@debbugs.gnu.org Cc: Nicolas Graves Received: via spool by 77541-submit@debbugs.gnu.org id=B77541.174379425927927 (code B ref 77541); Fri, 04 Apr 2025 19:18:08 +0000 Received: (at 77541) by debbugs.gnu.org; 4 Apr 2025 19:17:39 +0000 Received: from localhost ([127.0.0.1]:40030 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u0mXq-0007G8-Hm for submit@debbugs.gnu.org; Fri, 04 Apr 2025 15:17:39 -0400 Received: from 8.mo562.mail-out.ovh.net ([46.105.60.65]:57471) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u0mXj-0007EU-Qh for 77541@debbugs.gnu.org; Fri, 04 Apr 2025 15:17:32 -0400 Received: from director1.derp.mail-out.ovh.net (director1.derp.mail-out.ovh.net [51.68.80.175]) by mo562.mail-out.ovh.net (Postfix) with ESMTPS id 4ZTpJp4qwtz1ddd; Fri, 4 Apr 2025 19:17:30 +0000 (UTC) Received: from director1.derp.mail-out.ovh.net (director1.derp.mail-out.ovh.net. [127.0.0.1]) by director1.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP for <77541@debbugs.gnu.org>; Fri, 4 Apr 2025 19:17:30 +0000 (UTC) Received: from mta3.priv.ovhmail-u1.ea.mail.ovh.net (unknown [10.108.17.113]) by director1.derp.mail-out.ovh.net (Postfix) with ESMTPS id 4ZTpJp32gqzHp3j; Fri, 4 Apr 2025 19:17:30 +0000 (UTC) Received: from ngraves.fr (unknown [10.1.6.1]) by mta3.priv.ovhmail-u1.ea.mail.ovh.net (Postfix) with ESMTPSA id B52B63A3EA6; Fri, 4 Apr 2025 19:17:29 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-114S008c88dc79c-3933-42e4-97b8-dfd958d72d02, 5C763BAE2B049B0552D0CEA89988AE409CD35AAA) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 90.92.117.144 Date: Fri, 4 Apr 2025 21:16:43 +0200 Message-ID: <20250404191717.32747-11-ngraves@ngraves.fr> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250404191717.32747-1-ngraves@ngraves.fr> References: <20250404191717.32747-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3479593664245195490 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduledvvdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepleffjeetueethfefkeffffefvddukeejkefgleduiedthfekvefhiedvhfffgeegnecukfhppeduvdejrddtrddtrddupdeltddrledvrdduudejrddugeegnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepvddprhgtphhtthhopeejjeehgeduseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdfovfetjfhoshhtpehmohehiedvmgdpmhhouggvpehsmhhtphhouhht DKIM-Signature: a=rsa-sha256; bh=Bt14lIzipCMSo+u1yb6zqxKsjqnovthSam03fUgNxsw=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1743794250; v=1; b=lm6mKdbs2/uuwzWb1QOTjqsaVmBblGuAU+9UqTLihBLpU6SruO2IfzlSwLKB9Y8nwrFqPRsv SQF156RuR79ZgBCCMlUwr293KxFhD6+FFT3f8jDnstU4HIavDE2p/zerVJWcV7v0PrGvvVSqdnk mjOYpFCYtNXpFCZDmCNAlf9NMJVkhlo9bGcnhDDhUaZzVMaQz2I7+o6119r8/9lt0B/e1NoACkw gVOoz2/FKu3fPjff9dLG/qyiimvLstQ4FXu2cCJ2CLtBGv0fxK3v8nL6M6gySFTvTrEWEqFI1gd 9DiRB5PK3Pf0Y7v3jO6t7W5o57qNmG112UN6s9d5fXrpg== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/python-xyz.scm (python-property-cached): Fix build. * gnu/packages/patches/python-property-cached-asyncio-3_11.patch: Add patch. * gnu/local.mk: Record patch. --- gnu/local.mk | 1 + .../python-property-cached-asyncio-3_11.patch | 201 ++++++++++++++++++ gnu/packages/python-xyz.scm | 4 +- 3 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/python-property-cached-asyncio-3_11.patch diff --git a/gnu/local.mk b/gnu/local.mk index 93f346481d..1bf8f8deba 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2129,6 +2129,7 @@ dist_patch_DATA = \ %D%/packages/patches/python-memcached-syntax-warnings.patch \ %D%/packages/patches/python-mox3-python3.6-compat.patch \ %D%/packages/patches/python-packaging-test-arch.patch \ + %D%/packages/patches/python-property-cached-asyncio-3_11.patch \ %D%/packages/patches/python-pyan3-fix-absolute-path-bug.patch \ %D%/packages/patches/python-pyan3-fix-positional-arguments.patch \ %D%/packages/patches/python-pytorch-fix-codegen.patch \ diff --git a/gnu/packages/patches/python-property-cached-asyncio-3_11.patch b/gnu/packages/patches/python-property-cached-asyncio-3_11.patch new file mode 100644 index 0000000000..21c176947e --- /dev/null +++ b/gnu/packages/patches/python-property-cached-asyncio-3_11.patch @@ -0,0 +1,201 @@ +From d89186b47dc25c5ef5907c146edf3f792d50774b Mon Sep 17 00:00:00 2001 +Message-ID: +From: Nicolas Graves +Date: Wed, 2 Apr 2025 17:29:45 +0200 +Subject: [PATCH] Update to python 3.11 + +--- + property_cached/__init__.py | 21 +++------- + tests/test_async_cached_property.py | 3 +- + tests/test_coroutine_cached_property.py | 51 ++++++++++--------------- + 3 files changed, 27 insertions(+), 48 deletions(-) + +diff --git a/property_cached/__init__.py b/property_cached/__init__.py +index 3353048..c033542 100644 +--- a/property_cached/__init__.py ++++ b/property_cached/__init__.py +@@ -3,6 +3,7 @@ import functools + import pkg_resources + import threading + import weakref ++from inspect import iscoroutinefunction + from time import time + + +@@ -31,12 +32,12 @@ class cached_property(property): + if obj is None: + return self + +- if asyncio and asyncio.iscoroutinefunction(self.func): +- return self._wrap_in_coroutine(obj) +- + value = self.cache.get(obj, self._sentinel) + if value is self._sentinel: +- value = self.cache[obj] = self.func(obj) ++ if iscoroutinefunction(self.func): ++ self.cache[obj] = value = asyncio.ensure_future(self.func(obj)) ++ else: ++ self.cache[obj] = value = self.func(obj) + + return value + +@@ -49,18 +50,6 @@ class cached_property(property): + def __delete__(self, obj): + del self.cache[obj] + +- def _wrap_in_coroutine(self, obj): +- +- @functools.wraps(obj) +- @asyncio.coroutine +- def wrapper(): +- value = self.cache.get(obj, self._sentinel) +- if value is self._sentinel: +- self.cache[obj] = value = asyncio.ensure_future(self.func(obj)) +- return value +- +- return wrapper() +- + + class threaded_cached_property(cached_property): + """ +diff --git a/tests/test_async_cached_property.py b/tests/test_async_cached_property.py +index 1af139d..32b3410 100644 +--- a/tests/test_async_cached_property.py ++++ b/tests/test_async_cached_property.py +@@ -9,8 +9,7 @@ import property_cached as 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) + +diff --git a/tests/test_coroutine_cached_property.py b/tests/test_coroutine_cached_property.py +index 40e443b..5864301 100644 +--- a/tests/test_coroutine_cached_property.py ++++ b/tests/test_coroutine_cached_property.py +@@ -14,8 +14,7 @@ import property_cached as 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) + +@@ -33,14 +32,12 @@ def CheckFactory(cached_property_decorator): + self.control_total = 0 + self.cached_total = 0 + +- @asyncio.coroutine +- def add_control(self): ++ async def add_control(self): + self.control_total += 1 + return self.control_total + + @cached_property_decorator +- @asyncio.coroutine +- def add_cached(self): ++ async def add_cached(self): + self.cached_total += 1 + return self.cached_total + +@@ -52,74 +49,68 @@ class TestCachedProperty(unittest.TestCase): + + cached_property_factory = cached_property.cached_property + +- @asyncio.coroutine +- def assert_control(self, check, expected): ++ async def assert_control(self, check, expected): + """ + Assert that both `add_control` and 'control_total` equal `expected` + """ +- value = yield from check.add_control() ++ value = await check.add_control() + self.assertEqual(value, expected) + self.assertEqual(check.control_total, expected) + +- @asyncio.coroutine +- def assert_cached(self, check, expected): ++ async def assert_cached(self, check, expected): + """ + Assert that both `add_cached` and 'cached_total` equal `expected` + """ + print("assert_cached", check.add_cached) +- value = yield from check.add_cached ++ value = await check.add_cached + self.assertEqual(value, expected) + self.assertEqual(check.cached_total, expected) + + @unittest_run_loop +- @asyncio.coroutine +- def test_cached_property(self): ++ async def test_cached_property(self): + Check = CheckFactory(self.cached_property_factory) + check = Check() + + # The control shows that we can continue to add 1 +- yield from self.assert_control(check, 1) +- yield from self.assert_control(check, 2) ++ await self.assert_control(check, 1) ++ await self.assert_control(check, 2) + + # The cached version demonstrates how nothing is added after the first +- yield from self.assert_cached(check, 1) +- yield from self.assert_cached(check, 1) ++ await self.assert_cached(check, 1) ++ await self.assert_cached(check, 1) + + # The cache does not expire + with freeze_time("9999-01-01"): +- yield from self.assert_cached(check, 1) ++ await self.assert_cached(check, 1) + + # Typically descriptors return themselves if accessed though the class + # rather than through an instance. + self.assertTrue(isinstance(Check.add_cached, self.cached_property_factory)) + + @unittest_run_loop +- @asyncio.coroutine +- def test_reset_cached_property(self): ++ async def test_reset_cached_property(self): + Check = CheckFactory(self.cached_property_factory) + check = Check() + + # Run standard cache assertion +- yield from self.assert_cached(check, 1) +- yield from self.assert_cached(check, 1) ++ await self.assert_cached(check, 1) ++ await self.assert_cached(check, 1) + + # Clear the cache + del check.add_cached + + # Value is cached again after the next access +- yield from self.assert_cached(check, 2) +- yield from self.assert_cached(check, 2) ++ await self.assert_cached(check, 2) ++ await self.assert_cached(check, 2) + + @unittest_run_loop +- @asyncio.coroutine +- def test_none_cached_property(self): ++ async def test_none_cached_property(self): + class Check(object): + def __init__(self): + self.cached_total = None + + @self.cached_property_factory +- @asyncio.coroutine +- def add_cached(self): ++ async def add_cached(self): + return self.cached_total + +- yield from self.assert_cached(Check(), None) ++ await self.assert_cached(Check(), None) +-- +2.49.0 + diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm index 46efd10292..01dfc0799f 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -11700,7 +11700,9 @@ (define-public python-property-cached (method url-fetch) (uri (pypi-uri "property-cached" version ".zip")) (sha256 - (base32 "0wxv5sdx1p7ils36j6j6hfscz8v2vzbq212i8y8r0lrnxpqlx71y")))) + (base32 "0wxv5sdx1p7ils36j6j6hfscz8v2vzbq212i8y8r0lrnxpqlx71y")) + (patches + (search-patches "python-property-cached-asyncio-3_11.patch")))) (build-system pyproject-build-system) (arguments (list