-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·90 lines (78 loc) · 3.45 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·90 lines (78 loc) · 3.45 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
# Forge dev environment setup.
#
# Creates a conda env, editable-installs forge with test deps, wires the
# dogfood pre-commit hook via .githooks/install.sh, and runs forge-doctor to
# verify the install. This is the self-test rig: forge uses it to prove its
# own standards (pre-commit hook, ruff config, doctor) work end-to-end.
#
# Not shipped via pip. Lives under dev/ so it stays clearly out of the
# consumer-facing surface.
#
# Usage:
# ./dev/setup.sh # env name: forge (or .conda_env_name)
# CONDA_ENV_NAME=forge_dev ./dev/setup.sh # override env name
# PYTHON_VERSION=3.12 ./dev/setup.sh # override python version
#
# Env name is resolved by dev/get_conda_env_name.sh:
# $CONDA_ENV_NAME env var > .conda_env_name file (repo root) > "forge".
# Drop a .conda_env_name file at the repo root (see .conda_env_name.example)
# to give parallel clones (dev-0, dev-1, ...) their own conda envs.
#
# Re-run safe: skips steps already done.
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$REPO_ROOT"
# Resolve ENV_NAME: $CONDA_ENV_NAME > .conda_env_name file > "forge".
# shellcheck source=dev/get_conda_env_name.sh
source "$REPO_ROOT/dev/get_conda_env_name.sh"
PYTHON_VERSION="${PYTHON_VERSION:-3.13}"
# 1. Require conda.
if ! command -v conda >/dev/null 2>&1; then
echo -e "${RED}conda not on PATH.${NC} Install Miniconda or Anaconda first:"
echo " https://docs.conda.io/projects/miniconda/en/latest/"
exit 1
fi
# Source conda activate machinery (needed in non-interactive shells).
CONDA_BASE="$(conda info --base)"
# shellcheck source=/dev/null
source "$CONDA_BASE/etc/profile.d/conda.sh"
# 2. Create env if missing.
if conda env list | awk '{print $1}' | grep -qx "$ENV_NAME"; then
echo -e "${GREEN}✓${NC} conda env '$ENV_NAME' already exists"
else
echo -e "${YELLOW}→${NC} creating conda env '$ENV_NAME' (python=$PYTHON_VERSION)..."
conda create -y -n "$ENV_NAME" "python=$PYTHON_VERSION"
fi
# 3. Activate.
conda activate "$ENV_NAME"
# Sanity-check we're in the right env.
if [ "${CONDA_DEFAULT_ENV:-}" != "$ENV_NAME" ]; then
echo -e "${RED}Failed to activate '$ENV_NAME'.${NC}"
exit 1
fi
# 4. Editable install with the full contributor umbrella (test + audit +
# typecheck). forge's own dev env should carry every tool it ships and
# dogfoods — pytest, the audit deps (vulture / jsonschema / PyYAML), and
# pyrefly for the opt-in typecheck step. `[dev]` is that umbrella.
echo -e "${YELLOW}→${NC} pip install -e .[dev]"
pip install -e ".[dev]"
# 5. Run the consumer-facing umbrella installer. Dogfood: forge is the
# source of install-forge-bootstrap, so running it here exercises the
# same path every consumer follows. --skip claude-md because forge IS
# the source of FOUNDATION.md (root file is a symlink to
# src/forge/data/FOUNDATION.md); install-forge-claude-md would wrap
# the source with managed markers and corrupt it.
echo -e "${YELLOW}→${NC} install-forge-bootstrap --skip claude-md"
install-forge-bootstrap --skip claude-md || {
echo -e "${YELLOW}install-forge-bootstrap reported failures.${NC} Review output above."
}
echo ""
echo -e "${GREEN}Setup complete.${NC}"
echo " Activate the env in new shells: conda activate $ENV_NAME"
echo " Run tests: pytest tests/"
echo " Pre-commit hook fires on commit (validate manually: .githooks/pre-commit)"