]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use the right python when mkosi is a symlink
authorGeorges Discry <georges@discry.be>
Tue, 15 Nov 2022 11:22:31 +0000 (12:22 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Tue, 15 Nov 2022 13:31:12 +0000 (14:31 +0100)
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.

bin/mkosi

index 7bbc7344586f6d8c83781984a62467ef99ed204d..3fac96b2a849cd63c409d2d580b32039c8c84689 100755 (executable)
--- a/bin/mkosi
+++ b/bin/mkosi
@@ -13,6 +13,7 @@
 #   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
@@ -22,7 +23,7 @@
 # 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