Use [importlib.metadata](https://docs.python.org/3/library/importlib.metadata.html) to find the version of the installed package. See https://gitlab.wikimedia.org/repos/ci-tools/commit-message-validator/-/commit/64a3b58411f8dd3773516504556d22bee1465ff1 as an implementation example including support for older versions of Python.