git: d68a0effe94d - main - devel/py-inotify-simple: use native inotify on FreeBSD 15+

From: Xin LI <delphij_at_FreeBSD.org>
Date: Fri, 11 Sep 2026 05:43:12 UTC
The branch main has been updated by delphij:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d68a0effe94d7416f270d524e47edd65dfbb2519

commit d68a0effe94d7416f270d524e47edd65dfbb2519
Author:     Xin LI <delphij@FreeBSD.org>
AuthorDate: 2026-03-01 07:25:06 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2026-09-11 05:42:40 +0000

    devel/py-inotify-simple: use native inotify on FreeBSD 15+
    
    FreeBSD 15 (OSVERSION >= 1500051) provides native inotify in libc.
    Use native libc on FreeBSD 15+ and Linux; fall back to libinotify on
    older FreeBSD releases which require the kqueue-based emulation.
    
    Remove unconditional LIB_DEPENDS on libinotify and make it conditional
    using the bsd.port.pre.mk/bsd.port.post.mk split.
    
    PR:             ports/294447
    Approved by:    maintainer timeout
---
 devel/py-inotify-simple/Makefile                       | 11 ++++++++---
 devel/py-inotify-simple/files/patch-inotify__simple.py | 13 ++++++++++---
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/devel/py-inotify-simple/Makefile b/devel/py-inotify-simple/Makefile
index c1ea5c6694c2..cb40b5be476a 100644
--- a/devel/py-inotify-simple/Makefile
+++ b/devel/py-inotify-simple/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	inotify-simple
 PORTVERSION=	2.0.1
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	devel python
 MASTER_SITES=	PYPI
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -16,11 +16,16 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}setuptools>=0:devel/py-setuptools@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}wheel>=0:devel/py-wheel@${PY_FLAVOR}
 
-LIB_DEPENDS=	libinotify.so:devel/libinotify
-
 USES=		python
 USE_PYTHON=	autoplist pep517
 
 NO_ARCH=	yes
 
+.include <bsd.port.options.mk>
+
+# Native inotify is in libc since FreeBSD 15 (OSVERSION 1500051); older releases need libinotify
+.if ${OPSYS} == FreeBSD && ${OSVERSION} < 1500051
+LIB_DEPENDS=	libinotify.so:devel/libinotify
+.endif
+
 .include <bsd.port.mk>
diff --git a/devel/py-inotify-simple/files/patch-inotify__simple.py b/devel/py-inotify-simple/files/patch-inotify__simple.py
index 776f877be4d8..69cbd635abbf 100644
--- a/devel/py-inotify-simple/files/patch-inotify__simple.py
+++ b/devel/py-inotify-simple/files/patch-inotify__simple.py
@@ -1,6 +1,6 @@
 --- inotify_simple.py.orig	2025-08-25 06:27:48 UTC
 +++ inotify_simple.py
-@@ -3,6 +3,7 @@ from enum import IntEnum
+@@ -3,6 +3,7 @@ from select import poll
  from collections import namedtuple
  from struct import unpack_from, calcsize
  from select import poll
@@ -8,12 +8,19 @@
  from time import sleep
  from ctypes import CDLL, get_errno, c_int
  from ctypes.util import find_library
-@@ -76,12 +77,12 @@ class INotify(FileIO):
+@@ -76,12 +77,19 @@ class INotify(FileIO):
                  object is garbage collected or when `~inotify_simple.INotify.close` is
                  called."""
              
 -        global _libc; _libc = _libc or CDLL(find_library('c'), use_errno=True)
-+        global _libc; _libc = _libc or CDLL(find_library('inotify'), use_errno=True)
++        global _libc
++        if _libc is None:
++            _uname = os.uname()
++            if _uname.sysname == 'FreeBSD' and \
++                    int(_uname.release.split('.')[0]) < 15:
++                _libc = CDLL(find_library('inotify'), use_errno=True)
++            else:
++                _libc = CDLL(find_library('c'), use_errno=True)
          flags = (not inheritable) * os.O_CLOEXEC | bool(nonblocking) * os.O_NONBLOCK
          fd = _libc_call(_libc.inotify_init1, flags)
          super().__init__(fd, mode='rb', closefd=closefd)