When the `mkosi` on the `PATH` is a symlink to the script installed
inside a virtualenv, the script fails to find the python executable
inside the virtualenv and falls back to the main python3. This is
notably the case when installing mkosi with pipx.
By first following the symlink inside the virtualenv, the script can
find the corresponding python executable.
# python3 -m pip install --user <mkosi>
# python3 -m pip install --user --editable <mkosi>
# /path/to/venv/bin/python3 -m pip install <mkosi>
+# pipx install <mkosi>
# and running directly from the source checkout.
#
# In the first and the next-to-last cases this script is a noop because we leave
# cloned to, for "--editable" installations, when this script is run via sudo.
# When running from a source checkout, we prepend that directory to the path.
-PYROOT=$(dirname "$0")
+PYROOT="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
if [[ -x "${PYROOT}/python3" ]]
then