diff options
Diffstat (limited to 'bin/pyexec')
| -rwxr-xr-x | bin/pyexec | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bin/pyexec b/bin/pyexec new file mode 100755 index 0000000..303bc4b --- /dev/null +++ b/bin/pyexec @@ -0,0 +1,27 @@ +#!/bin/bash + +set -euo pipefail + +debug() { + if [[ "${DEBUG:-}" == "pyexec" ]]; then + >&2 echo "[DEBUG=pyexec]" "$@" + fi +} + +if [[ -n "${VIRTUAL_ENV:-}" ]]; then + debug "Detected VIRTUAL_ENV" + i=python +elif [[ -r ".venv/bin/activate" ]]; then + debug "Found .venv, activating" + source .venv/bin/activate + i=python +elif command -v python3 >/dev/null; then + debug "Found python3 in path" + i=python3 +else + debug "Defaulting to python" + i=python +fi + +exec "$i" "$@" + |
