commit:     60cf96d728c2b1c6ad2557cebc51377114e27962
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Nov  8 08:13:42 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Nov  8 08:32:30 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=60cf96d7

dev-python/pyinotify: Enable py3.12

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../pyinotify/files/pyinotify-0.9.6-py312.patch    | 84 ++++++++++++++++++++++
 dev-python/pyinotify/pyinotify-0.9.6-r1.ebuild     | 14 ++--
 2 files changed, 94 insertions(+), 4 deletions(-)

diff --git a/dev-python/pyinotify/files/pyinotify-0.9.6-py312.patch 
b/dev-python/pyinotify/files/pyinotify-0.9.6-py312.patch
new file mode 100644
index 000000000000..6f8f65545b8c
--- /dev/null
+++ b/dev-python/pyinotify/files/pyinotify-0.9.6-py312.patch
@@ -0,0 +1,84 @@
+From 478d595a7d086423733e9f5da5edfe9f1df48682 Mon Sep 17 00:00:00 2001
+From: Troy Curtis Jr <[email protected]>
+Date: Thu, 10 Aug 2023 21:51:15 -0400
+Subject: [PATCH] Make asyncore support optional for Python 3.
+
+Fixes #204.
+---
+ python3/pyinotify.py | 50 +++++++++++++++++++++++++-------------------
+ 1 file changed, 28 insertions(+), 22 deletions(-)
+
+diff --git a/python3/pyinotify.py b/python3/pyinotify.py
+index bc24313..f4a5a90 100755
+--- a/python3/pyinotify.py
++++ b/python3/pyinotify.py
+@@ -68,7 +68,6 @@ def __init__(self, version):
+ from datetime import datetime, timedelta
+ import time
+ import re
+-import asyncore
+ import glob
+ import locale
+ import subprocess
+@@ -1494,33 +1493,40 @@ def run(self):
+         self.loop()
+ 
+ 
+-class AsyncNotifier(asyncore.file_dispatcher, Notifier):
+-    """
+-    This notifier inherits from asyncore.file_dispatcher in order to be able 
to
+-    use pyinotify along with the asyncore framework.
++try:
++    import asyncore
+ 
+-    """
+-    def __init__(self, watch_manager, default_proc_fun=None, read_freq=0,
+-                 threshold=0, timeout=None, channel_map=None):
++    class AsyncNotifier(asyncore.file_dispatcher, Notifier):
+         """
+-        Initializes the async notifier. The only additional parameter is
+-        'channel_map' which is the optional asyncore private map. See
+-        Notifier class for the meaning of the others parameters.
++        This notifier inherits from asyncore.file_dispatcher in order to be 
able to
++        use pyinotify along with the asyncore framework.
+ 
+         """
+-        Notifier.__init__(self, watch_manager, default_proc_fun, read_freq,
+-                          threshold, timeout)
+-        asyncore.file_dispatcher.__init__(self, self._fd, channel_map)
++        def __init__(self, watch_manager, default_proc_fun=None, read_freq=0,
++                     threshold=0, timeout=None, channel_map=None):
++            """
++            Initializes the async notifier. The only additional parameter is
++            'channel_map' which is the optional asyncore private map. See
++            Notifier class for the meaning of the others parameters.
+ 
+-    def handle_read(self):
+-        """
+-        When asyncore tells us we can read from the fd, we proceed processing
+-        events. This method can be overridden for handling a notification
+-        differently.
++            """
++            Notifier.__init__(self, watch_manager, default_proc_fun, 
read_freq,
++                              threshold, timeout)
++            asyncore.file_dispatcher.__init__(self, self._fd, channel_map)
+ 
+-        """
+-        self.read_events()
+-        self.process_events()
++        def handle_read(self):
++            """
++            When asyncore tells us we can read from the fd, we proceed 
processing
++            events. This method can be overridden for handling a notification
++            differently.
++
++            """
++            self.read_events()
++            self.process_events()
++except ImportError:
++    # asyncore was removed in Python 3.12, but try the import instead of a
++    # version check in case the compatibility package is installed.
++    pass
+ 
+ 
+ class TornadoAsyncNotifier(Notifier):

diff --git a/dev-python/pyinotify/pyinotify-0.9.6-r1.ebuild 
b/dev-python/pyinotify/pyinotify-0.9.6-r1.ebuild
index e634cade25b1..2398f2c70957 100644
--- a/dev-python/pyinotify/pyinotify-0.9.6-r1.ebuild
+++ b/dev-python/pyinotify/pyinotify-0.9.6-r1.ebuild
@@ -4,8 +4,7 @@
 EAPI=8
 
 DISTUTILS_USE_PEP517=setuptools
-# py3.12 does not work, see https://github.com/seb-m/pyinotify/issues/204
-PYTHON_COMPAT=( python3_{10..11} pypy3 )
+PYTHON_COMPAT=( python3_{10..12} pypy3 )
 PYTHON_REQ_USE="threads(+)"
 
 inherit distutils-r1
@@ -13,14 +12,21 @@ inherit distutils-r1
 DESCRIPTION="Python module used for monitoring filesystems events"
 HOMEPAGE="
        https://pypi.org/project/pyinotify/
-       https://github.com/seb-m/pyinotify/";
-SRC_URI="https://seb.dbzteam.org/pub/pyinotify/releases/${P}.tar.gz";
+       https://github.com/seb-m/pyinotify/
+"
+SRC_URI="
+       https://seb.dbzteam.org/pub/pyinotify/releases/${P}.tar.gz
+"
 
 LICENSE="MIT"
 SLOT="0"
 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~mips ppc ppc64 ~riscv 
~s390 sparc x86 ~amd64-linux ~x86-linux"
 IUSE="examples"
 
+PATCHES=(
+       "${FILESDIR}/${P}-py312.patch"
+)
+
 python_install_all() {
        if use examples; then
                dodoc -r python3/examples

Reply via email to