mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-09-09 17:35:34 +00:00
This update ensures that console scripts in the virtual environment do not retain outdated shebangs pointing to temporary build paths. The `--update-venv` command now rewrites shebangs in place, allowing broken installs to recover without a full rebuild. Additionally, all pip invocations now use `python -m pip` to prevent issues with stale shebangs. This change addresses issue #229 and improves the overall reliability of the service installation process.
39 lines
1.2 KiB
Bash
Executable File
39 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Rewrite absolute shebangs in a virtualenv's bin/ scripts after the tree has
|
|
# been relocated. `python -m venv` and pip bake the creation path into console
|
|
# scripts; an atomic mv from .venv-build-$$ to venv/ leaves those shebangs
|
|
# pointing at a path that no longer exists ("cannot execute: required file not
|
|
# found"). Symlinked interpreters (python, python3, …) are left alone.
|
|
#
|
|
# Usage: rewrite_venv_shebangs.sh /path/to/venv
|
|
set -euo pipefail
|
|
|
|
venv="${1:?usage: $0 /path/to/venv}"
|
|
new_python="$venv/bin/python"
|
|
|
|
if [ ! -x "$new_python" ]; then
|
|
echo "rewrite_venv_shebangs: no usable interpreter at $new_python" >&2
|
|
exit 1
|
|
fi
|
|
|
|
shopt -s nullglob
|
|
for script in "$venv/bin"/*; do
|
|
[ -f "$script" ] || continue
|
|
[ -L "$script" ] && continue
|
|
|
|
first="$(head -n 1 "$script" 2>/dev/null || true)"
|
|
case "$first" in
|
|
"#!"*"python"*)
|
|
if [ "$first" = "#!$new_python" ]; then
|
|
continue
|
|
fi
|
|
{
|
|
printf '#!%s\n' "$new_python"
|
|
tail -n +2 "$script"
|
|
} >"$script.tmp"
|
|
mv "$script.tmp" "$script"
|
|
chmod a+rx "$script"
|
|
;;
|
|
esac
|
|
done
|