Skip to content

Commit

Permalink
Backport changes since v1.0 to Python 2.7 (#756)
Browse files Browse the repository at this point in the history
* Fix installation of Python 3.7.9 on Windows (#705)

* [windows] winapi.BUFFER_SIZE now defaults to 64000 (instead of 2048)

To handle cases with lot of changes, this seems the highest safest value we can use.

Note: it will fail with `ERROR_INVALID_PARAMETER` when it is greater than 64 KB and
      the application is monitoring a directory over the network.
      This is due to a packet size limitation with the underlying file sharing protocols.
      https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-readdirectorychangesw#remarks

Also introduced `winapi.PATH_BUFFER_SIZE` (defaults to `2048`)
to keep the old behavior with path-realted functions.

* [mac] Regression fixes for native fsevents (#717)

* [mac] Fix missing event_id attribute in fsevents (#722)

* [mac] Return byte paths if a byte path was given in fsevents (#726)

* Pin py.test to a version that supports 2.7

* Disable pypy2 tests on Windows

They hang and timeout after 6 hours for some unknown reason

* [mac] Add compatibility with old macOS versions (#733)

* Ensure version macros are available

* Uniformize event for deletion of watched dir (#727)

* [inotify] Add support for the IN_CLOSE_WRITE event (#747)

* [mac] Support coalesced fsevents (#734)

* Add `is_coalesced` property to `NativeEvent`

So that we can effectively decide if we need to perform additional
system calls to figure out what really happened.

* Replace `NativeEvent._event_type` with `repr()` support

It's more pythonic, and the `_event_type` implementation wasn't quite
usable anyway.

NB: the representation is not truly copy/paste python code if there is
a double quote inside event.path, but that should be a rare case so we
don't add the expensive special case handling there.

* Allow running tests with debugger attached

Some Python debuggers create additional threads, so we shouldn't assume that there is only one.

* Request notifications for watched root

* Expect events on macOS instead of using `time.sleep()`

It might be even better to check for the emitter class, as opposed to platform

* Add exception handling to FSEventsEmitter

Reduce the amount of 'silent breakage'

* Use sentinel event when setting up tests on macOS

So that we can avoid a race between test setup and fseventsd

* Improve handling of coalesced events

* Revert accidental platform check change

* Fix renaming_top_level_directory test on macOS

* Generate sub events for move operations

* Remove `filesystem_view` again

While the `filesystem_view` helps with filtering out additional
`FileCreatedEvent`+`DirModifiedEvent` pairs then it also introduces
a huge amount of edge cases for synthetic events caused by move and
rename operations. On top of that, in order to properly resolve
those edge cases we'd have to go back to a solution very similar to
the old directory snapshots, with all the performance penalties they
suffered from...

As such I think it's better to acknowledge the behaviour for coalesced
events instead, and thus remove the `filesystem_view` again.

* [mac] Improve handling of rename events (#750)

* drop support for macOS 10.12 and lower

Co-authored-by: SamSchott <ss2151@cam.ac.uk>
Co-authored-by: Boris Staletic <boris.staletic@gmail.com>
Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
Co-authored-by: Dustin Ingram <di@users.noreply.github.com>
Co-authored-by: ysard <ysard@users.noreply.github.com>
Co-authored-by: Lukas Šupienis <l.supienis@ncs.lt>
Co-authored-by: Lukas Šupienis <lukas.supienis@gmail.com>
  • Loading branch information
8 people committed Feb 5, 2021
1 parent cf9b81a commit e7f29d1
Show file tree
Hide file tree
Showing 63 changed files with 767 additions and 584 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/testrunner.yml
@@ -0,0 +1,31 @@
name: "Python 2.7 & 3.5 tests"

on: [push]

jobs:
build:
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
max-parallel: 3
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
python-version: [2.7, 3.5, pypy2]
exclude:
# the pypy2 on Windows tests appear to hang, so let's disable it until we can figure out why
- os: windows-latest
python-version: pypy2
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{matrix.python-version}}
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python-version}}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-tests.txt
- name: flake8
run: python -m flake8 docs tools src tests
- name: pytest
run: python -bb -m pytest --showlocals -v --cov=watchdog --cov-report=term-missing
81 changes: 0 additions & 81 deletions .travis.yml

This file was deleted.

9 changes: 6 additions & 3 deletions AUTHORS
@@ -1,7 +1,11 @@
Project Lead:
-------------
Original Project Lead:
----------------------
Yesudeep Mangalapilly <yesudeep@google.com>

Current Project Lead:
---------------------
Mickaël Schoentgen <contact@tiger-222.fr>

Contributors in alphabetical order:
-----------------------------------
Adrian Tejn Kern <tejnkern@gmail.com>
Expand All @@ -19,7 +23,6 @@ Lukáš Lalinský <lalinsky@gmail.com>
Malthe Borch <mborch@gmail.com>
Martin Kreichgauer <kreichgauer@gmail.com>
Martin Kreichgauer <martin@kreichgauer.com>
Mickaël Schoentgen <mschoentgen@nuxeo.com>
Mike Lundy <mike@fluffypenguin.org>
Raymond Hettinger <python@rcn.com>
Roman Ovchinnikov <coolthecold@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion COPYING
@@ -1,5 +1,5 @@
Copyright 2011 Yesudeep Mangalapilly <yesudeep@gmail.com>
Copyright 2012 Google, Inc.
Copyright 2012 Google, Inc & contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
27 changes: 17 additions & 10 deletions README.rst
Expand Up @@ -18,6 +18,7 @@ If you want to use Python 3.6 and newer versions with up-to-date patches, you sh

Example API Usage
-----------------

A simple program that uses watchdog to monitor directories specified
as command-line arguments and logs events generated:

Expand Down Expand Up @@ -48,6 +49,7 @@ as command-line arguments and logs events generated:
Shell Utilities
---------------

Watchdog comes with an *optional* utility script called ``watchmedo``.
Please type ``watchmedo --help`` at the shell prompt to
know more about this tool.
Expand Down Expand Up @@ -84,6 +86,7 @@ Please see the help information for these commands by typing:
About ``watchmedo`` Tricks
~~~~~~~~~~~~~~~~~~~~~~~~~~

``watchmedo`` can read ``tricks.yaml`` files and execute tricks within them in
response to file system events. Tricks are actually event handlers that
subclass ``watchdog.tricks.Trick`` and are written by plugin authors. Trick
Expand Down Expand Up @@ -120,20 +123,16 @@ The directory containing the ``tricks.yaml`` file will be monitored. Each trick
class is initialized with its corresponding keys in the ``tricks.yaml`` file as
arguments and events are fed to an instance of this class as they arrive.

Tricks will be included in the 0.5.0 release. I need community input about them.
Please file enhancement requests at the `issue tracker`_.


Installation
------------
Install from PyPI using ``pip``:

.. code-block:: bash
$ python -m pip install watchdog
$ python -m pip install -U watchdog
# or to install the watchmedo utility:
$ python -m pip install watchdog[watchmedo]
$ python -m pip install -U watchdog[watchmedo]
Install from source:

Expand All @@ -147,6 +146,7 @@ Install from source:
Installation Caveats
~~~~~~~~~~~~~~~~~~~~

The ``watchmedo`` script depends on PyYAML_ which links with LibYAML_,
which brings a performance boost to the PyYAML parser. However, installing
LibYAML_ is optional but recommended. On Mac OS X, you can use homebrew_
Expand All @@ -161,31 +161,34 @@ do it on Ubuntu:

.. code-block:: bash
$ sudo aptitude install libyaml-dev
$ sudo apt install libyaml-dev
On Windows, please install PyYAML_ using the binaries they provide.

Documentation
-------------

You can browse the latest release documentation_ online.

Contribute
----------

Fork the `repository`_ on GitHub and send a pull request, or file an issue
ticket at the `issue tracker`_. For general help and questions use the official
`mailing list`_ or ask on `stackoverflow`_ with tag `python-watchdog`.

Create and activate your virtual environment, then::

python -m pip install pytest pytest-cov
python -m pip install -e .[watchmedo]
python -m pip install -e ".[watchmedo]"
python -m pytest tests

If you are making a substantial change, add an entry to the "Unreleased" section
of the `changelog`_.

Supported Platforms
-------------------

* Linux 2.6 (inotify)
* Mac OS X (FSEvents, kqueue)
* FreeBSD/BSD (kqueue)
Expand Down Expand Up @@ -214,6 +217,7 @@ files.

About using watchdog with editors like Vim
------------------------------------------

Vim does not modify files unless directed to do so.
It creates backup files and then swaps them in to replace
the files you are editing on the disk. This means that
Expand All @@ -225,6 +229,7 @@ this feature.

About using watchdog with CIFS
------------------------------

When you want to watch changes in CIFS, you need to explicitly tell watchdog to
use ``PollingObserver``, that is, instead of letting watchdog decide an
appropriate observer like in the example above, do::
Expand All @@ -234,6 +239,7 @@ appropriate observer like in the example above, do::

Dependencies
------------

1. Python 2.7, 3.4 or 3.5.
2. pathtools_
3. XCode_ (only on Mac OS X)
Expand All @@ -243,17 +249,19 @@ Dependencies

Licensing
---------

Watchdog is licensed under the terms of the `Apache License, version 2.0`_.

Copyright 2011 `Yesudeep Mangalapilly`_.

Copyright 2012 Google, Inc.
Copyright 2012 Google, Inc & contributors.

Project `source code`_ is available at Github. Please report bugs and file
enhancement requests at the `issue tracker`_.

Why Watchdog?
-------------

Too many people tried to do the same thing and none did what I needed Python
to do:

Expand Down Expand Up @@ -285,7 +293,6 @@ to do:
.. _PyYAML: http://www.pyyaml.org/
.. _XCode: http://developer.apple.com/technologies/tools/xcode.html
.. _LibYAML: http://pyyaml.org/wiki/LibYAML
.. _pathtools: http://github.com/gorakhargosh/pathtools

.. _pnotify: http://mark.heily.com/pnotify
.. _unison fsmonitor: https://webdav.seas.upenn.edu/viewvc/unison/trunk/src/fsmonitor.py?view=markup&pathrev=471
Expand Down
15 changes: 14 additions & 1 deletion changelog.rst
Expand Up @@ -8,7 +8,20 @@ Changelog

202x-xx-xx • `full history <https://github.com/gorakhargosh/watchdog/compare/v0.10.6...python-2.7>`__

- Thanks to our beloved contributors:
- [backport 1.0.0] [mac] Regression fixes for native ``fsevents`` (`#717 <https://github.com/gorakhargosh/watchdog/pull/717>`_)
- [backport 1.0.0] [windows] ``winapi.BUFFER_SIZE`` now defaults to ``64000`` (instead of ``2048``) (`#700 <https://github.com/gorakhargosh/watchdog/pull/700>`_)
- [backport 1.0.0] [windows] Introduced ``winapi.PATH_BUFFER_SIZE`` (defaults to ``2048``) to keep the old behavior with path-realted functions (`#700 <https://github.com/gorakhargosh/watchdog/pull/700>`_)
- [backport 1.0.0] Removed the long-time deprecated ``events.LoggingFileSystemEventHandler`` class, use ``LoggingEventHandler`` instead
- [backport 1.0.2] Wheels are published for GNU/Linux, macOS and Windows (`#739 <https://github.com/gorakhargosh/watchdog/pull/739>`_)
- [backport 1.0.2] [mac] Fix missing ``event_id`` attribute in ``fsevents`` (`#721 <https://github.com/gorakhargosh/watchdog/pull/721>`_)
- [backport 1.0.2] [mac] Return byte paths if a byte path was given in ``fsevents`` (`#726` <https://github.com/gorakhargosh/watchdog/pull/726>`_)
- [backport 1.0.2] [mac] Add compatibility with old macOS versions (`#733` <https://github.com/gorakhargosh/watchdog/pull/733>`_)
- [backport 1.0.2] Uniformize event for deletion of watched dir (`#727 <https://github.com/gorakhargosh/watchdog/pull/727>`_)
- [backport 2.0.0] [inotify] Add support for ``IN_CLOSE_WRITE`` events. A ``FileCloseEvent`` event will be fired. Note that ``IN_CLOSE_NOWRITE`` events are not handled to prevent much noise. (`#184 <https://github.com/gorakhargosh/watchdog/pull/184>`_, `#245 <https://github.com/gorakhargosh/watchdog/pull/245>`_, `#280 <https://github.com/gorakhargosh/watchdog/pull/280>`_, `#313 <https://github.com/gorakhargosh/watchdog/pull/313>`_, `#690 <https://github.com/gorakhargosh/watchdog/pull/690>`_)
- [backport 2.0.0] [mac] Support coalesced filesystem events (`#734 <https://github.com/gorakhargosh/watchdog/pull/734>`_)
- [backport 2.0.0] [mac] Drop support for OSX 10.12 and earlier (`#750 <https://github.com/gorakhargosh/watchdog/pull/750>`_)
- [backport 2.0.0] [mac] Fix an issue when renaming an item changes only the casing (`#750 <https://github.com/gorakhargosh/watchdog/pull/750>`_)
- Thanks to our beloved contributors: @SamSchott, @bstaletic, @BoboTiG, @CCP-Aporia, @di, @lukassup, @ysard


0.10.6
Expand Down
3 changes: 1 addition & 2 deletions docs/_fsevents.pyx
@@ -1,5 +1,4 @@
#!/usr/bin/env cython
# -*- coding: utf-8 -*-
# coding: utf-8

cdef extern from "CoreFoundation/CoreFoundation.h":
struct dummy:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding: utf-8
#
# watchdog documentation build configuration file, created by
# sphinx-quickstart on Tue Nov 30 00:43:58 2010.
Expand Down
3 changes: 1 addition & 2 deletions docs/source/examples/logger.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# coding: utf-8

import sys
import time
Expand Down
3 changes: 1 addition & 2 deletions docs/source/examples/patterns.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# coding: utf-8

import sys
import time
Expand Down
3 changes: 1 addition & 2 deletions docs/source/examples/simple.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# coding: utf-8

import logging
import sys
Expand Down
2 changes: 1 addition & 1 deletion docs/source/global.rst.inc
Expand Up @@ -2,7 +2,7 @@

.. |author_name| replace:: Yesudeep Mangalapilly
.. |author_email| replace:: yesudeep@gmail.com
.. |copyright| replace:: Copyright 2012 Google, Inc.
.. |copyright| replace:: Copyright 2012 Google, Inc & contributors.
.. |project_name| replace:: ``watchdog``
.. |project_version| replace:: 0.10.7

Expand Down
10 changes: 5 additions & 5 deletions docs/source/hacking.rst
Expand Up @@ -37,21 +37,21 @@ Steps to setting up a clean environment:
$ cd watchdog
$ pip install virtualenv
$ virtualenv venv
3. Linux

For example Debian and Python 2.7:
For example Debian and Python 2.7:

.. code:: bash
$ sudo apt-get install python-pip python-virtualenv
For Python 3:

.. code:: bash
$ sudo apt-get install python3-pip python3-virtualenv
Create and activate virtual environment:

.. code:: bash
Expand Down

0 comments on commit e7f29d1

Please sign in to comment.