"""Prepare source-built executables and the unmodified published native dependencies.
Run beside the other drivers; BASE_CHECKOUT and HEAD_CHECKOUT name isolated installed checkouts.
No production state or database is read. Build sequentially.
"""
import os,subprocess,shutil
from pathlib import Path
R=Path(__file__).parent
for side in ['base','head']:
 checkout=Path(os.environ[side.upper()+'_CHECKOUT'])
 for version,label in [('0.1.9','old'),('0.1.10','target'),('0.1.11','second-target')]:
  subprocess.run(['vp','run','build:exe'],cwd=checkout/'apps/server',env={**os.environ,'APP_VERSION':version},check=True)
  shutil.copy2(checkout/'apps/server/dist-exe/t3',R/(side+'-'+label+'-t3'))
head=Path(os.environ['HEAD_CHECKOUT'])
subprocess.run(['sh',str(head/'scripts/install.sh')],env={**os.environ,'T3CODE_HOME':str(R/'download-home'),'T3CODE_INSTALL_BIN_DIR':str(R/'download-bin'),'T3CODE_VERSION':'0.1.10-nightly.20261114.4695'},check=True)
# reproduce.py uses BASE_CHECKOUT/HEAD_CHECKOUT when supplied; otherwise the prescribed worktree names.
