This is a demonstration on how to write and set up a simple git hook with Python as scripting language and Poetry as dependency management tool.
The goal is to have the hook run in an isolated environment (a.k.a. virtualenv) each time, thus not interfering with other libraries or versions already installed on your system.
The only requirement besides a proper installation of Python 3+ is the Poetry tool. In Mac OS X you can install Poetry with Homebrew:
$ brew install poetry
For other systems you may want to check the documentation.
First grab the tarball with the git hook from the Releases section and then issue the following commands:
$ cd <my-project>/
$ tar xvzf version-enforcer-0.1.0.tgz
x .git/hooks/version-enforcer/
x .git/hooks/version-enforcer/enforce.py
x .git/hooks/version-enforcer/pyproject.toml
x .git/hooks/pre-push
$ (cd .git/hooks/version-enforcer && poetry install)