#!/usr/bin/env bash # # Copyright 2009-2024 Joshua Bronson. All rights reserved. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # shellcheck disable=SC1091 set -euo pipefail declare -r hint="Hint: Use 'nix develop' to bootstrap a development environment" source ./dev-deps/dev.env for cmd in "$DEFAULT_PY" uv pre-commit; do if ! type "$cmd"; then >&2 echo "Error: No '$cmd' on PATH. $hint" exit 1 fi done pre-commit install -f if ! test -d "$VENV_DIR"; then uv venv --python="$DEFAULT_PY" "$VENV_DIR" fi declare -r req_sets="dev docs test" declare -r out_dir="dev-deps/$DEFAULT_PY" mkdir -p "$out_dir" for i in $req_sets; do reqs_in="dev-deps/$i.in" reqs_out="$out_dir/$i.txt" # The following options should match those passed in dev-deps/update_dev_dependencies so that the # resulting "autogenerated...via the following command:" comments match. uv pip compile --upgrade --python-version="$DEFAULT_PY_VER" "$reqs_in" -o "$reqs_out" done uv pip sync "$out_dir"/*.txt # TODO Use the following instead of the line after once we pick up a new enough uv (0.1.16+): # if ! uv pip show -q bidict; then if ! uv pip freeze | grep -q ^bidict; then uv pip install -e . fi echo "Development virtualenv initialized: $VENV_DIR" echo "To activate, run: source $VENV_DIR/bin/activate (or equivalent for your shell)"