]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager/poe: allow kresctl to be run under Python <3.8
authorOto Šťáva <oto.stava@nic.cz>
Thu, 24 Aug 2023 06:21:40 +0000 (08:21 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 24 Aug 2023 08:14:16 +0000 (08:14 +0000)
manager/poe
manager/pyproject.toml

index abcc2a8d6f2ee9b172e98c20665c6cce3922c012..290652809cd8af626ad83d1c6962507b80169c99 100755 (executable)
@@ -3,9 +3,17 @@
 script_dir="$(dirname "$(readlink -f "$0")")"
 
 if poetry --directory "$script_dir" run python -c 'import sys; sys.exit(0 if sys.version_info >= (3, 8) else 1)'; then
+    # Run poethepoet with the project root in the $script_dir directory (requires Python >=3.8)
     poetry --directory "$script_dir" run poe --root "$script_dir" $@
 elif [ "$PWD" == "$script_dir" ]; then
-    poetry run poe $@
+    # Compatibility workarounds for Python <3.8 and poethepoet <0.22.0
+    # Only works if the current working directory is the same as the script directory.
+    args=("$@")
+    if [ "${args[0]}" == "kresctl" ]; then
+        echo "WARNING: Workaround for Python <3.8: replacing 'kresctl' with 'kresctl-nocwd'" >&2
+        args[0]="kresctl-nocwd"
+    fi
+    poetry run poe "${args[@]}"
 else
     echo "Running script from non project root is not supported for current 'poethepoet' version." >&2
     echo "poethepoet version - must be >=0.22.0" >&2
index 49b34cd547d9b5991ba5d3625a8454be78ecb467..c1f70b1aab665c34aac6dd176f8ac963bff1ffb1 100644 (file)
@@ -69,6 +69,7 @@ fixdeps = { shell = "poetry install; npm install; npm update", help = "Install/u
 commit = { shell = "scripts/commit", help = "Invoke every single check before commiting" }
 container = { cmd = "scripts/container.py", help = "Manage containers" }
 kresctl = { script = "knot_resolver_manager.cli.main:main", cwd="${POE_PWD}", help="run kresctl" }
+kresctl-nocwd = { script = "knot_resolver_manager.cli.main:main", help="run kresctl" } # Python <3.8 and poethepoet <0.22.0 compatibility (see also `./poe`)
 clean = """
   rm -rf .coverage
          .mypy_cache