-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
init_dev_env
executable file
·52 lines (43 loc) · 1.43 KB
/
init_dev_env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/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" 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
if type uv; then
uv venv --python="$DEFAULT_PY" "$VENV_DIR"
else
"$DEFAULT_PY" -m venv "$VENV_DIR"
source "$VENV_DIR"/bin/activate
pip install uv
fi
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 --python-version="$DEFAULT_PY_VER" "$reqs_in" -o "$reqs_out"
done
uv pip sync "$out_dir"/*.txt
if ! uv pip show -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)"