Skip to content

A python extension to gather filesystem events generated by the operating system (macOS) for a specific path

Notifications You must be signed in to change notification settings

nilleb/fsevents-watcher

Repository files navigation

fsevents_watcher

A python extension to gather filesystem events generated by the operating system (macOS) for a specific path. Have a look at macos_watcher.py for an example.

requirements

  • homebrew (used to pull other requirements)
  • xcode devutils
  • golang (used to compile the go code)
  • pkg-config (used to generate the header files)

bootstrap

xcode-select --install  # installs xcode devutils
# make sure you have set your GOPATH
brew install pkg-config golang
mkdir -p $GOPATH/src/github.com/nilleb
cd $GOPATH/src/github.com/nilleb
git clone https://github.com/nilleb/fsevents-watcher
cd fsevents-watcher
# which python do you use? we try to detect it in the set-python-home.sh.
# if you feel it's not the right version, feel free to edit it.
./build.sh

# now you can:
# - launch the example by typing
./launch.sh
# - if you want to use the included mtime_file_watcher.py for your AppEngine dev_appserver.py
sudo python replace_mtime_file_watcher.py replace
# now you can start `dev_appserver.py` as usual
# - if you want to restore the original mtime_file_watcher.py,
sudo python replace_mtime_file_watcher.py restore

notes

has been tested on

  • Darwin 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64
  • Darwin 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64 i386 MacBookPro12,1 Darwin (homebrew python 2.7.13)
  • Darwin 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64 i386 MacBookPro13,1 Darwin (System Default Python Interpreter - 2.7.10 as of writing)
  • Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64 i386 MacBookPro12,1 Darwin

troubleshooting

python version mismatch

Fatal Python error: PyThreadState_Get: no current thread
./launch.sh: line 4: 52141 Abort trap: 6           $PYTHON_HOME/bin/python macos_watcher.py

Execute a otool -L fsevents_watcher.so and verify that the python path is the one of the python executable you are using to launch the code. If the path seems to be the same, check that the Python path exists. When using homebrew it is possible that some symlinks evolve with updates. If it is missing, you should be able to create a symbolic link to the right version.

If the path differs, you can try the follow:

  • check what commands are being issued by the golang comiler and linker, editing build.sh and adding the -x flag at the end of the last line
  • verify that the path of the python library being linked is the one pointed by otool
  • check that you have installed homebrew python, and the pkg-config files brew ls python or brew ls python@2 and inspect the output of those two commands. if they contain a folder named pkg-config you're halfway to the solution
  • if this is the case, try setting the PKG_CONFIG_PATH to the full path of the pkg-config folder listed by brew
  • if this is not the case, you could try reinstalling homebrew python

Usually, a homebrew install ends with a message like:

==> [email protected]
Python has been installed as
  /usr/local/opt/[email protected]/bin/python3

You can install Python packages with
  /usr/local/opt/[email protected]/bin/pip3 install <package>
They will install into the site-package directory
  /usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages

See: https://docs.brew.sh/Homebrew-and-Python

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"

I suppose that a solution to this problem would be to execute the command:

export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"

permission denied while replacing the mtime file watcher

IOError: [Errno 13] Permission denied: '/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/mtime_file_watcher.py' Have you typed sudo before the replace_mtime_file_watcher.py invocation?

gcloud components update

If you update the gcloud components, you shall re-replace the mtime_file_watcher.py again..

About

A python extension to gather filesystem events generated by the operating system (macOS) for a specific path

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •