Skip to content

Commit bcc2133

Browse files
hoomanclaude
andcommitted
feat: add managed Python venv with platform-specific setup/build/validate scripts
Replace ad-hoc dependency installation with a formal virtual environment workflow: - Add requirements.txt with pinned minimum versions for all dependencies - Add .python-version (3.11) for pyenv/asdf integration - Add scripts/setup.sh and setup.bat to create .venv/ with system dep auto-install (Homebrew on macOS, apt on Linux, winget/MSYS2 guidance on Windows) - Add scripts/validate.sh and validate.bat with component selection (all/entities/briefs) - Add scripts/build.sh and build.bat with component selection (all/entities/briefs/pdf) - Remove unsafe --break-system-packages auto-install hacks from pipeline scripts - Update CI workflow to use requirements.txt and run all pipeline steps - Update all documentation to reference wrapper scripts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 41ff3a0 commit bcc2133

16 files changed

Lines changed: 619 additions & 72 deletions

.github/workflows/validate.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ jobs:
1414
python-version: '3.11'
1515

1616
- name: Install dependencies
17-
run: pip install pyyaml jsonschema jinja2 ftfy
17+
run: pip install -r requirements.txt
1818

1919
- name: Validate schemas and cross-references
20-
run: python pipeline/validate.py
20+
run: |
21+
python pipeline/validate.py
22+
python pipeline/validate_briefs.py
2123
2224
- name: Build outputs
23-
run: python pipeline/build.py
25+
run: |
26+
python pipeline/build.py
27+
python pipeline/build_briefs.py

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
__pycache__/
33
*.pyc
44
*.pyo
5+
.venv/
56

67
# macOS
78
.DS_Store
@@ -10,7 +11,7 @@ __MACOSX/
1011
# Claude Code local state (worktrees, plans, settings)
1112
.claude/
1213

13-
# Generated artifacts — rebuild with: python3 build.py
14+
# Generated artifacts — rebuild with: bash scripts/build.sh
1415
# Excluded to keep repo size manageable for project knowledge sync
1516
output/
1617

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

docs/ARCHITECTURE.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ A4, Georgia serif, running page numbers. Brief assembly order controlled by
221221
CLI options:
222222

223223
```bash
224-
python pipeline/build_pdf.py # both tiers
225-
python pipeline/build_pdf.py --briefs-only # Tier 1 only
226-
python pipeline/build_pdf.py --full-only # Tier 2 only
227-
python pipeline/build_pdf.py --date 2026-03-04 # override release date
224+
bash scripts/build.sh pdf # both tiers
225+
bash scripts/build.sh pdf --briefs-only # Tier 1 only
226+
bash scripts/build.sh pdf --full-only # Tier 2 only
227+
bash scripts/build.sh pdf --date 2026-03-04 # override release date
228228
```
229229

230230
---
@@ -234,13 +234,13 @@ python pipeline/build_pdf.py --date 2026-03-04 # override release date
234234
```bash
235235
# 1. Edit YAML source files in data/
236236
# 2. Validate
237-
python pipeline/validate.py && python pipeline/validate_briefs.py
237+
bash scripts/validate.sh
238238
239239
# 3. Build markdown
240-
python pipeline/build.py && python pipeline/build_briefs.py
240+
bash scripts/build.sh
241241
242242
# 4. Build PDFs
243-
python pipeline/build_pdf.py
243+
bash scripts/build.sh pdf
244244
245245
# 5. Commit source changes only (output/ and releases/ are gitignored)
246246
git add data/ schemas/ templates/ pipeline/ scripts/ docs/ *.md

docs/CLAUDE_CODE_INSTRUCTIONS.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,42 @@ framework/
9494

9595
---
9696

97+
## Environment Setup
98+
99+
Requires Python 3.9+ (3.11+ recommended). Run once to create the virtual environment:
100+
101+
```bash
102+
# macOS / Linux
103+
bash scripts/setup.sh
104+
105+
# Windows
106+
scripts\setup.bat
107+
```
108+
109+
This creates `.venv/` with all dependencies from `requirements.txt`.
110+
111+
---
112+
97113
## Core Rules
98114

99115
### Rule 1: Never edit output/*.md files
100116
These are generated artifacts. Edit the YAML source, then rebuild.
101117

102118
### Rule 2: Validate before every commit
103119
```bash
104-
python pipeline/validate.py # entities + content modules
105-
python pipeline/validate_briefs.py # briefs
106-
python pipeline/validate.py variables # single entity type
120+
bash scripts/validate.sh # everything (entities + briefs)
121+
bash scripts/validate.sh entities # entities + content modules only
122+
bash scripts/validate.sh briefs # briefs only
123+
bash scripts/validate.sh variables # single entity type
107124
```
108125

109126
### Rule 3: Build after every data change
110127
```bash
111-
python pipeline/build.py # entity reports + content modules
112-
python pipeline/build_briefs.py # convergence briefs
113-
python pipeline/build.py variables # one report only
114-
python pipeline/build.py content # content modules only
115-
python pipeline/build.py --validate # validate then build
128+
bash scripts/build.sh # everything (entities + briefs)
129+
bash scripts/build.sh entities # entity reports + content modules
130+
bash scripts/build.sh briefs # convergence briefs
131+
bash scripts/build.sh pdf # PDF releases
132+
bash scripts/build.sh --validate # validate then build all
116133
```
117134

118135
### Rule 4: Atomic updates
@@ -415,11 +432,11 @@ When a Claude session produces an Integration Spec, translate it to database ope
415432
6. **Version bump** → update `version`, `date`, `source` metadata fields
416433
7. **Validate:**
417434
```bash
418-
python pipeline/validate.py && python pipeline/validate_briefs.py
435+
bash scripts/validate.sh
419436
```
420437
8. **Build:**
421438
```bash
422-
python pipeline/build.py && python pipeline/build_briefs.py
439+
bash scripts/build.sh
423440
```
424441
9. **Commit** (output/ and releases/ are gitignored — do not use `git add -A`):
425442
```bash
@@ -434,10 +451,10 @@ When a Claude session produces an Integration Spec, translate it to database ope
434451
After data integration and build:
435452

436453
```bash
437-
python pipeline/build_pdf.py # both tiers → releases/
438-
python pipeline/build_pdf.py --briefs-only # Tier 1 only
439-
python pipeline/build_pdf.py --full-only # Tier 2 only
440-
python pipeline/build_pdf.py --date 2026-03-05 # override release date
454+
bash scripts/build.sh pdf # both tiers → releases/
455+
bash scripts/build.sh pdf --briefs-only # Tier 1 only
456+
bash scripts/build.sh pdf --full-only # Tier 2 only
457+
bash scripts/build.sh pdf --date 2026-03-05 # override release date
441458
```
442459

443460
Then create a GitHub Release tagged `v{YYYY-MM-DD}` and attach the PDFs from
@@ -524,8 +541,8 @@ specified fields. Fields not listed are left unchanged.
524541
a. Read files from `staging/session_N/`
525542
b. Full files → copy to `data/` target path
526543
c. Patch files → merge field updates into existing YAML
527-
d. Validate: `python pipeline/validate.py && python pipeline/validate_briefs.py`
528-
e. Build: `python pipeline/build.py && python pipeline/build_briefs.py`
544+
d. Validate: `bash scripts/validate.sh`
545+
e. Build: `bash scripts/build.sh`
529546
3. Delete the consumed `staging/session_N/` directory
530547
4. Commit everything atomically:
531548
```bash

docs/GUIDE_ENGINEERS.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,18 @@ Add this to your LLM project configuration:
131131
### Quick Start
132132

133133
```bash
134-
pip install pyyaml jsonschema jinja2 ftfy weasyprint markdown
135-
136-
python pipeline/validate.py && python pipeline/validate_briefs.py # validate all
137-
python pipeline/build.py && python pipeline/build_briefs.py # build markdown
138-
python pipeline/build_pdf.py # build PDF releases
134+
# One-time setup (creates .venv/ with all dependencies)
135+
bash scripts/setup.sh # macOS / Linux
136+
scripts\setup.bat # Windows
137+
138+
# Run the pipeline
139+
bash scripts/validate.sh # validate all
140+
bash scripts/build.sh # build markdown
141+
bash scripts/build.sh pdf # build PDF releases
139142
```
140143

141-
All commands run from the repository root.
144+
All commands run from the repository root. The wrapper scripts handle
145+
virtual environment activation automatically.
142146

143147
### What Each Script Does
144148

pipeline/README.md

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,53 @@ Build and validation scripts for the ITP analytical database.
1010
| `build_briefs.py` | Render brief YAML to markdown |
1111
| `build_pdf.py` | Convert rendered markdown to PDF releases |
1212

13+
## Setup
14+
15+
Requires Python 3.9+ (3.11+ recommended). Run the setup script once to create a virtual environment:
16+
17+
```bash
18+
# macOS / Linux
19+
bash scripts/setup.sh
20+
21+
# Windows
22+
scripts\setup.bat
23+
```
24+
25+
This creates `.venv/` with all dependencies from `requirements.txt`.
26+
1327
## Usage
1428

15-
Run from the **repository root**:
29+
Use the wrapper scripts (they activate the virtual environment automatically):
1630

1731
```bash
18-
python pipeline/validate.py # validate all entities
19-
python pipeline/validate.py modules # validate one entity type
20-
python pipeline/validate_briefs.py # validate briefs
21-
python pipeline/build.py # build all output
22-
python pipeline/build_pdf.py # generate PDF releases
32+
# macOS / Linux
33+
bash scripts/validate.sh # validate everything
34+
bash scripts/validate.sh entities # entities only
35+
bash scripts/validate.sh briefs # briefs only
36+
bash scripts/validate.sh variables # single entity type
37+
38+
bash scripts/build.sh # build everything
39+
bash scripts/build.sh briefs # briefs only
40+
bash scripts/build.sh pdf # PDF releases
41+
bash scripts/build.sh --validate # validate then build
42+
43+
# Windows
44+
scripts\validate.bat
45+
scripts\build.bat
2346
```
2447

25-
## Dependencies
48+
Or run pipeline scripts directly (with the virtual environment activated):
2649

2750
```bash
28-
pip install pyyaml jsonschema jinja2 ftfy weasyprint
51+
source .venv/bin/activate # macOS / Linux
52+
python pipeline/validate.py
53+
python pipeline/build.py
54+
deactivate
2955
```
56+
57+
## Dependencies
58+
59+
Managed via `requirements.txt` in the repository root. Core pipeline needs
60+
`pyyaml`, `jsonschema`, `jinja2`, `ftfy`. PDF generation additionally needs
61+
`weasyprint` and `markdown` (plus system libraries — see `requirements.txt`
62+
for platform-specific install notes).

pipeline/build_briefs.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,8 @@
55
import sys
66
from pathlib import Path
77

8-
try:
9-
import yaml
10-
except ImportError:
11-
import subprocess
12-
subprocess.check_call([sys.executable, "-m", "pip", "install",
13-
"pyyaml", "--break-system-packages", "-q"])
14-
import yaml
15-
16-
try:
17-
import jinja2
18-
except ImportError:
19-
import subprocess
20-
subprocess.check_call([sys.executable, "-m", "pip", "install",
21-
"jinja2", "--break-system-packages", "-q"])
22-
import jinja2
8+
import yaml
9+
import jinja2
2310

2411

2512
BASE = Path(__file__).resolve().parent.parent

pipeline/validate_briefs.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,8 @@
55
import sys
66
from pathlib import Path
77

8-
# jsonschema may need install
9-
try:
10-
import jsonschema
11-
except ImportError:
12-
import subprocess
13-
subprocess.check_call([sys.executable, "-m", "pip", "install",
14-
"jsonschema", "--break-system-packages", "-q"])
15-
import jsonschema
16-
17-
try:
18-
import yaml
19-
except ImportError:
20-
import subprocess
21-
subprocess.check_call([sys.executable, "-m", "pip", "install",
22-
"pyyaml", "--break-system-packages", "-q"])
23-
import yaml
8+
import jsonschema
9+
import yaml
2410

2511

2612
BASE = Path(__file__).resolve().parent.parent

requirements.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ITP Framework — Python dependencies
2+
# Install into a virtual environment: pip install -r requirements.txt
3+
#
4+
# Core pipeline (validate + build)
5+
pyyaml>=6.0.1
6+
jsonschema>=4.21.0
7+
jinja2>=3.1.3
8+
ftfy>=6.2.0
9+
10+
# PDF generation (optional — only needed for `build_pdf.py`)
11+
# WeasyPrint requires system libraries: Cairo, Pango, GDK-PixBuf.
12+
# macOS: brew install cairo pango gdk-pixbuf libffi
13+
# Ubuntu: apt install libcairo2 libpango-1.0-0 libgdk-pixbuf2.0-0 libffi-dev
14+
# Windows: See https://doc.courtbouillon.org/weasyprint/stable/first_steps.html
15+
weasyprint>=62.0
16+
markdown>=3.6

0 commit comments

Comments
 (0)