Skip to content

Commit 2ecaf04

Browse files
blitztideBoboTiG
andauthored
feat: better solution to support FreeBSD in the future (#1148)
* Support Inotify on FreeBSD 15+ * Revise changelog for version 6.0.0 updates Updated changelog to reflect recent changes and contributions. * Better solution that's forward compatible * Apply suggestions from code review * Update changelog.rst * Apply suggestion from @BoboTiG --------- Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
1 parent ef4bfe9 commit 2ecaf04

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Changelog
1414

1515
**Other Changes**
1616

17-
- [freebsd] Supports ``inotify`` on FreeBSD 15. (`#1147 <https://github.com/gorakhargosh/watchdog/pull/1147>`__)
17+
- [freebsd] Supports ``inotify`` on FreeBSD 15+. (`#1147 <https://github.com/gorakhargosh/watchdog/pull/1147>`__)
1818
- [core] Adjust ``Observer.schedule()`` ``path`` type annotation to reflect the ``pathlib.Path`` support. (`#1096 <https://github.com/gorakhargosh/watchdog/pull/1096>`__)
1919
- [core] Add support for the ``follow_symlink`` keyword argument to ``ObservedWatch``. (`#1086 <https://github.com/gorakhargosh/watchdog/pull/1086>`__)
2020
- [fsevents] Add support for the ``follow_symlink`` keyword argument. (`#1086 <https://github.com/gorakhargosh/watchdog/pull/1086>`__)

src/watchdog/utils/platform.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
import sys
3+
import sys, os
44

55
PLATFORM_WINDOWS = "windows"
66
PLATFORM_LINUX = "linux"
@@ -19,10 +19,14 @@ def get_platform_name() -> str:
1919
if sys.platform.startswith("linux"):
2020
return PLATFORM_LINUX
2121

22-
if sys.platform == "freebsd15": # FreeBSD 15+ supports inotify
23-
return PLATFORM_LINUX
22+
if sys.platform.startswith("freebsd"):
23+
release = os.uname().release
24+
major = int(release.split(".", 1)[0])
25+
if major >= 15:
26+
return PLATFORM_LINUX # FreeBSD 15+ have full inotify support
27+
return PLATFORM_BSD
2428

25-
if sys.platform.startswith(("dragonfly", "freebsd", "netbsd", "openbsd", "bsd")):
29+
if sys.platform.startswith(("dragonfly", "netbsd", "openbsd", "bsd")):
2630
return PLATFORM_BSD
2731

2832
return PLATFORM_UNKNOWN

0 commit comments

Comments
 (0)