| 1 |
#!/usr/bin/env bash |
| 2 |
# |
| 3 |
# Copyright 2009-2024 Joshua Bronson. All rights reserved. |
| 4 |
# |
| 5 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
|
| 9 |
# shellcheck disable=SC2086,SC1091 |
| 10 |
|
| 11 |
|
| 12 |
set -euo pipefail |
| 13 |
|
| 14 |
log() { |
| 15 |
>&2 printf "> %s\n" "$@" |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
main() { |
| 20 |
local -r dotslash="$(dirname "$(readlink -f "$0")")" |
| 21 |
source "$dotslash/py_ver.env" |
| 22 |
if ! type "$DEFAULT_PY"; then |
| 23 |
log "Error: No $DEFAULT_PY on PATH. Hint: Check /init_dev_env and try again." |
| 24 |
exit 1 |
| 25 |
fi |
| 26 |
local -r venv_dir="$dotslash/../.venv" |
| 27 |
if [ ! -e "$venv_dir/bin/$DEFAULT_PY" ]; then |
| 28 |
log "Error: No such file "$venv_dir/bin/$DEFAULT_PY". Hint: Check /init_dev_env and try again." |
| 29 |
exit 2 |
| 30 |
fi |
| 31 |
if ! type "pre-commit"; then |
| 32 |
log "Error: pre-commit not found in PATH." |
| 33 |
exit 3 |
| 34 |
fi |
| 35 |
|
| 36 |
local -r pip_compile_pfx="uv pip compile --generate-hashes --upgrade" |
| 37 |
for py in python3.12 python3.11 python3.10 python3.9 python3.8 pypy3.10 pypy3.9; do |
| 38 |
if ! $py -m sysconfig >/dev/null; then |
| 39 |
log "Detected broken $py installation -> skipping" |
| 40 |
continue |
| 41 |
fi |
| 42 |
local py_ver pip_compile |
| 43 |
py_ver="$(echo "$py" | grep -o '3\.[0-9]\+')" |
| 44 |
pip_compile="$pip_compile_pfx --python-version=$py_ver" |
| 45 |
$pip_compile dev-deps/test.in -o "dev-deps/$py/test.txt" >/dev/null |
| 46 |
# Compile remaining depsets just for our dev interpreter: |
| 47 |
if [ "$py" = "$DEFAULT_PY" ]; then |
| 48 |
for depset in docs dev; do |
| 49 |
$pip_compile "dev-deps/$depset.in" -o "dev-deps/$py/$depset.txt" |
| 50 |
done |
| 51 |
fi |
| 52 |
done |
| 53 |
log "Upgrading PyPI dependencies: Done" |
| 54 |
|
| 55 |
log "Upgrading pre-commit hooks..." |
| 56 |
pre-commit autoupdate |
| 57 |
|
| 58 |
log "Done." |
| 59 |
log "Reminders:" |
| 60 |
log " - Re-run /init_dev_env when ready to sync the new requirements to the dev env." |
| 61 |
log " - Check release notes of upgraded packages for anything that affects bidict." |
| 62 |
log " - Ensure tests pass for all supported Python versions." |
| 63 |
log " - Check output for any new warnings, not just test failures." |
| 64 |
log " - Ensure 'pre-commit run --all-files' still succeeds." |
| 65 |
} |
| 66 |
|
| 67 |
main |