#!/usr/bin/env bash # SPDX-FileCopyrightText: Defame1297 and contributors # SPDX-License-Identifier: GPL-3.0-or-later # # Regenerate requirements-dev.lock, the hashed lock of requirements-dev.txt (#113). # # scripts/lock-requirements.sh # # Needs the network (PyPI) and Python 3.13+ (ansible-core 2.22; KAMINO_PYTHON overrides python3). # pip-tools is installed, at the pinned version below, into a throwaway virtualenv, never into # the project's .venv. Run it in the same pull request as any change to requirements-dev.txt, # then commit both files: scripts/check_requirements_lock.py (a pre-commit hook and the Lint job) # fails when they disagree. An image input changed, so the image version needs its bump as usual # (python3 scripts/bump_image_versions.py). set -euo pipefail pip_tools_version="7.5.2" python="${KAMINO_PYTHON:-python3}" if ! "$python" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 13) else 1)' 2>/dev/null; then echo "error: $python is missing or older than 3.13; set KAMINO_PYTHON=/path/to/python3.13" >&2 exit 1 fi root="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/.." && pwd)" tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT "$python" -m venv "$tmp/venv" "$tmp/venv/bin/pip" install --quiet --disable-pip-version-check "pip-tools==${pip_tools_version}" cd "$root" # --allow-unsafe: setuptools is a dependency of a tool here, and pip refuses an unpinned # requirement in a file that carries hashes. "$tmp/venv/bin/pip-compile" --quiet --generate-hashes --strip-extras --allow-unsafe --newline lf \ --output-file requirements-dev.lock requirements-dev.txt python3 scripts/check_requirements_lock.py echo "requirements-dev.lock regenerated; commit it with requirements-dev.txt."