chore(dev): move the dev tools from .venv to .venv-dev
uv uses .venv as its project environment, and `uv sync --frozen` removes every package that is not in uv.lock. The tools the git hooks need would go with it, so they get a directory of their own. Re-running scripts/dev-setup.sh switches the hooks of an older clone and leaves its .venv alone. Ignore rules and prunes cover both directories. Refs: #516 Assisted-by: Claude Code
This commit is contained in:
1 parent
b7b763e1fa
commit
f62097a748
12 files changed
+51
-23
No files matched your search
@@ -26,7 +26,7 @@ set -euo pipefail
|
||||
|
||||
# The repository is derived from this script's own location (symlinks resolved), never
|
||||
# from the caller's working directory: running it from another repository must not
|
||||
# create or remove that repository's .venv.
|
||||
# create or remove that repository's .venv-dev.
|
||||
script="$(readlink -f "${BASH_SOURCE[0]}")"
|
||||
root="$(git -C "$(dirname "$script")/.." rev-parse --show-toplevel)"
|
||||
cd "$root"
|
||||
@@ -122,19 +122,19 @@ if still="$(git -C "$root" config --get core.hooksPath)" && [ -n "$still" ]; the
|
||||
fi
|
||||
|
||||
# A virtualenv made by an older Python is rebuilt rather than reused.
|
||||
if [ -x .venv/bin/python ] && ! .venv/bin/python -c "$py_ok" 2>/dev/null; then
|
||||
rm -rf "$root/.venv"
|
||||
if [ -x .venv-dev/bin/python ] && ! .venv-dev/bin/python -c "$py_ok" 2>/dev/null; then
|
||||
rm -rf "$root/.venv-dev"
|
||||
fi
|
||||
[ -x .venv/bin/python ] || "$python" -m venv .venv
|
||||
.venv/bin/pip install --quiet --disable-pip-version-check --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
||||
.venv/bin/pre-commit install --install-hooks
|
||||
[ -x .venv-dev/bin/python ] || "$python" -m venv .venv-dev
|
||||
.venv-dev/bin/pip install --quiet --disable-pip-version-check --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
||||
.venv-dev/bin/pre-commit install --install-hooks
|
||||
|
||||
# The collections of requirements.yml, exactly as pinned, into this clone (.ansible/ is ignored by
|
||||
# git and by the Collection build). ANSIBLE_COLLECTIONS_PATH is set to the target for the install:
|
||||
# a copy found elsewhere (~/.ansible/collections) would be skipped as already installed.
|
||||
collections="$root/.ansible/collections"
|
||||
mkdir -p "$collections"
|
||||
ANSIBLE_COLLECTIONS_PATH="$collections" .venv/bin/ansible-galaxy collection install \
|
||||
ANSIBLE_COLLECTIONS_PATH="$collections" .venv-dev/bin/ansible-galaxy collection install \
|
||||
-r requirements.yml -p "$collections"
|
||||
|
||||
marker="# kamino-dev-setup: virtualenv first on PATH"
|
||||
@@ -150,7 +150,7 @@ for hook in pre-commit commit-msg pre-push; do
|
||||
{
|
||||
head -n 1 "$file"
|
||||
# %q shell-quotes the path: a repository path with spaces, quotes or $(...) is data.
|
||||
printf '%s\n' "$marker" "export PATH=$(printf '%q' "$root/.venv/bin"):\"\$PATH\""
|
||||
printf '%s\n' "$marker" "export PATH=$(printf '%q' "$root/.venv-dev/bin"):\"\$PATH\""
|
||||
tail -n +2 "$file"
|
||||
} > "$tmp"
|
||||
cat "$tmp" > "$file" # keeps the file mode of the hook
|
||||
@@ -179,4 +179,4 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Done: git commit now runs the hooks with the tools in $root/.venv/bin and the collections in $collections."
|
||||
echo "Done: git commit now runs the hooks with the tools in $root/.venv-dev/bin and the collections in $collections."
|
||||
Reference in new issue
Block a user