File size: 2,114 Bytes
fd11263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
set -euo pipefail

ENV_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_ROOT="$(cd "$ENV_DIR/../../.." && pwd)"
RUNTIME_DIR="${RUNTIME_DIR:-$WORKSPACE_ROOT/package}"
VENV="${VENV:-$RUNTIME_DIR/.venv}"
# The evaluation-specific eval-events projection and native OTLP export are
# maintained in the project's fork. Keep the dependency pinned to an
# immutable commit so a rebuilt environment is reproducible.
ADAPTER_REPO="${ADAPTER_REPO:-https://github.com/PiyiHan/coding-harness-tracing.git}"
ADAPTER_REV="${ADAPTER_REV:-5e89472683de3f2a2a7cfe5e12543462f4939a82}"
ADAPTER_SOURCE="${ADAPTER_SOURCE:-$RUNTIME_DIR/coding-harness-tracing}"

command -v uv >/dev/null 2>&1 || {
  echo "uv is required: https://docs.astral.sh/uv/getting-started/installation/" >&2
  exit 2
}
command -v git >/dev/null 2>&1 || {
  echo "git is required to install coding-harness-tracing" >&2
  exit 2
}

mkdir -p "$RUNTIME_DIR"
UV_PROJECT_ENVIRONMENT="$VENV" uv sync \
  --project "$ENV_DIR" \
  --locked \
  --python 3.12

if [[ ! -d "$ADAPTER_SOURCE/.git" ]]; then
  git clone "$ADAPTER_REPO" "$ADAPTER_SOURCE"
fi

current_rev="$(git --git-dir="$ADAPTER_SOURCE/.git" --work-tree="$ADAPTER_SOURCE" rev-parse HEAD)"
if [[ "$current_rev" != "$ADAPTER_REV" ]]; then
  if ! git --git-dir="$ADAPTER_SOURCE/.git" --work-tree="$ADAPTER_SOURCE" diff-index --quiet HEAD --; then
    echo "Adapter checkout has local changes and cannot switch revisions: $ADAPTER_SOURCE" >&2
    exit 2
  fi
  git --git-dir="$ADAPTER_SOURCE/.git" --work-tree="$ADAPTER_SOURCE" \
    fetch "$ADAPTER_REPO" "$ADAPTER_REV"
  git --git-dir="$ADAPTER_SOURCE/.git" --work-tree="$ADAPTER_SOURCE" \
    checkout --detach "$ADAPTER_REV"
fi

# The upstream wheel at this revision omits the OpenCode TypeScript plugin.
# Editable installation keeps that non-Python runtime asset available.
uv pip install \
  --python "$VENV/bin/python" \
  --no-deps \
  --editable "$ADAPTER_SOURCE"

"$VENV/bin/python" -c \
  'import sqlite3, jsonschema, yaml, openai; print(f"Native SQLite {sqlite3.sqlite_version}")'
echo "Python environment ready: $VENV"