git » python-pyinotify.git » commit df875e7

upgpkg: 0.9.6-14: patch asynccore for 3.12

author Jelle van der Waa
2024-04-13 10:01:11 UTC
committer Jelle van der Waa
2024-04-13 10:01:11 UTC
parent 0bb2c789ab173b6b8b1239370b358b9dfe8dd40d

upgpkg: 0.9.6-14: patch asynccore for 3.12

.SRCINFO +3 -1
PKGBUILD +10 -3
pyinotify-python-3.12-fix.patch +82 -0

diff --git a/.SRCINFO b/.SRCINFO
index 66c81b2..36514c5 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
 pkgbase = python-pyinotify
 	pkgdesc = Python module used for monitoring filesystems events on Linux platforms with inotify.
 	pkgver = 0.9.6
-	pkgrel = 13
+	pkgrel = 14
 	url = https://github.com/seb-m/pyinotify
 	arch = any
 	license = custom:MIT
@@ -9,6 +9,8 @@ pkgbase = python-pyinotify
 	makedepends = python-setuptools
 	depends = python
 	source = https://github.com/seb-m/pyinotify/archive/0.9.6.tar.gz
+	source = pyinotify-python-3.12-fix.patch
 	sha512sums = 144db691c1cdfd4e52b838b8ed839b8d50d84d26a91a59b7460c3170f58a1c96b3ce4f51e6273835835291781215a87b8f2d2d87d1abf012e4c14b2cd4b3f4cf
+	sha512sums = 5da85499b8a3e89dc13ce609a08804d778df53006b382c8e1ca2a5212bf5b62e006275b81d232fd6d3a554c392a1d756c1fca2b56bfd1124b9d6591feb70ea63
 
 pkgname = python-pyinotify
diff --git a/PKGBUILD b/PKGBUILD
index 2f9c0b3..d13affa 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -4,15 +4,22 @@
 
 pkgname=python-pyinotify
 pkgver=0.9.6
-pkgrel=13
+pkgrel=14
 pkgdesc='Python module used for monitoring filesystems events on Linux platforms with inotify.'
 arch=('any')
 url="https://github.com/seb-m/pyinotify"
 license=('custom:MIT')
 depends=('python')
 makedepends=('python' 'python-setuptools')
-source=("https://github.com/seb-m/pyinotify/archive/${pkgver}.tar.gz")
-sha512sums=('144db691c1cdfd4e52b838b8ed839b8d50d84d26a91a59b7460c3170f58a1c96b3ce4f51e6273835835291781215a87b8f2d2d87d1abf012e4c14b2cd4b3f4cf')
+source=("https://github.com/seb-m/pyinotify/archive/${pkgver}.tar.gz"
+	"pyinotify-python-3.12-fix.patch")
+sha512sums=('144db691c1cdfd4e52b838b8ed839b8d50d84d26a91a59b7460c3170f58a1c96b3ce4f51e6273835835291781215a87b8f2d2d87d1abf012e4c14b2cd4b3f4cf'
+            '5da85499b8a3e89dc13ce609a08804d778df53006b382c8e1ca2a5212bf5b62e006275b81d232fd6d3a554c392a1d756c1fca2b56bfd1124b9d6591feb70ea63')
+
+prepare() {
+  cd pyinotify-${pkgver}
+  patch -Np1 -i ${srcdir}/"pyinotify-python-3.12-fix.patch"
+}
 
 build() {
   cd pyinotify-${pkgver}
diff --git a/pyinotify-python-3.12-fix.patch b/pyinotify-python-3.12-fix.patch
new file mode 100644
index 0000000..565138b
--- /dev/null
+++ b/pyinotify-python-3.12-fix.patch
@@ -0,0 +1,82 @@
+commit 478d595a7d086423733e9f5da5edfe9f1df48682
+Author: Troy Curtis Jr <troy@troycurtisjr.com>
+Date:   Thu Aug 10 21:51:15 2023 -0400
+
+    Make asyncore support optional for Python 3.
+    
+    Fixes #204.
+
+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 @@ from collections import deque
+ from datetime import datetime, timedelta
+ import time
+ import re
+-import asyncore
+ import glob
+ import locale
+ import subprocess
+@@ -1494,33 +1493,40 @@ class ThreadedNotifier(threading.Thread, Notifier):
+         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):