1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 eventlet,
6 fetchPypi,
7 flaky,
8 pytest-cov-stub,
9 pytest-timeout,
10 pytestCheckHook,
11 pythonOlder,
12 pyyaml,
13 setuptools,
14}:
15
16buildPythonPackage rec {
17 pname = "watchdog";
18 version = "6.0.0";
19 pyproject = true;
20
21 src = fetchPypi {
22 inherit pname version;
23 hash = "sha256-nd98gv2jro4k3s2hM47eZuHJmIPbk3Edj7lB6qLYwoI=";
24 };
25
26 build-system = [ setuptools ];
27
28 optional-dependencies.watchmedo = [ pyyaml ];
29
30 nativeCheckInputs =
31 [
32 flaky
33 pytest-cov-stub
34 pytest-timeout
35 pytestCheckHook
36 ]
37 ++ optional-dependencies.watchmedo
38 ++ lib.optionals (pythonOlder "3.13") [ eventlet ];
39
40 postPatch = ''
41 substituteInPlace setup.cfg \
42 --replace "--cov=watchdog" "" \
43 --replace "--cov-report=term-missing" ""
44 '';
45
46 pytestFlagsArray =
47 [
48 "--deselect=tests/test_emitter.py::test_create_wrong_encoding"
49 "--deselect=tests/test_emitter.py::test_close"
50 # assert cap.out.splitlines(keepends=False).count('+++++ 0') == 2 != 3
51 "--deselect=tests/test_0_watchmedo.py::test_auto_restart_on_file_change_debounce"
52 ]
53 ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
54 # fails to stop process in teardown
55 "--deselect=tests/test_0_watchmedo.py::test_auto_restart_subprocess_termination"
56 ]
57 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
58 # FileCreationEvent != FileDeletionEvent
59 "--deselect=tests/test_emitter.py::test_separate_consecutive_moves"
60 "--deselect=tests/test_observers_polling.py::test___init__"
61 # segfaults
62 "--deselect=tests/test_delayed_queue.py::test_delayed_get"
63 "--deselect=tests/test_emitter.py::test_delete"
64 # AttributeError: '_thread.RLock' object has no attribute 'key'"
65 "--deselect=tests/test_skip_repeats_queue.py::test_eventlet_monkey_patching"
66 ]
67 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
68 # segfaults
69 "--deselect=tests/test_delayed_queue.py::test_delayed_get"
70 "--deselect=tests/test_0_watchmedo.py::test_tricks_from_file"
71 "--deselect=tests/test_fsevents.py::test_watcher_deletion_while_receiving_events_1"
72 "--deselect=tests/test_fsevents.py::test_watcher_deletion_while_receiving_events_2"
73 "--deselect=tests/test_skip_repeats_queue.py::test_eventlet_monkey_patching"
74 "--deselect=tests/test_fsevents.py::test_recursive_check_accepts_relative_paths"
75 # fsevents:fsevents.py:318 Unhandled exception in FSEventsEmitter
76 "--deselect=tests/test_fsevents.py::test_watchdog_recursive"
77 # SystemError: Cannot start fsevents stream. Use a kqueue or polling observer...
78 "--deselect=tests/test_fsevents.py::test_add_watch_twice"
79 # fsevents:fsevents.py:318 Unhandled exception in FSEventsEmitter
80 "--deselect=ests/test_fsevents.py::test_recursive_check_accepts_relative_paths"
81 # gets stuck
82 "--deselect=tests/test_fsevents.py::test_converting_cfstring_to_pyunicode"
83 ];
84
85 disabledTestPaths =
86 [
87 # tests timeout easily
88 "tests/test_inotify_buffer.py"
89 ]
90 ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
91 # segfaults the testsuite
92 "tests/test_emitter.py"
93 # unsupported on x86_64-darwin
94 "tests/test_fsevents.py"
95 ];
96
97 pythonImportsCheck = [ "watchdog" ];
98
99 meta = with lib; {
100 description = "Python API and shell utilities to monitor file system events";
101 mainProgram = "watchmedo";
102 homepage = "https://github.com/gorakhargosh/watchdog";
103 changelog = "https://github.com/gorakhargosh/watchdog/blob/v${version}/changelog.rst";
104 license = licenses.asl20;
105 maintainers = [ ];
106 };
107}