# 1. Clone the repository
git clone https://github.com/your-org/glassalpha.git
cd glassalpha
# 2. Set up development environment (one command does everything)
make dev-setupThat's it! This single command:
- Creates a virtual environment (
.venv/) - Installs the package in editable mode with all dependencies
- Installs git hooks (pre-commit and pre-push)
- Runs environment validation (
glassalpha doctor)
Editable mode (pip install -e .) is crucial because:
- Changes to source code are immediately active (no reinstall needed)
- Tests run against your current code, not a stale installed version
- Your environment stays in sync with the repository
Common Problem: Running tests with a stale installed version leads to confusing failures where:
- Tests pass locally but fail in CI
- Changes you make don't affect test results
- Different developers see different behavior
GlassAlpha uses a strict environment synchronization system to ensure:
- Your local venv matches the source code
- CI uses the same versions
- All contributors have consistent environments
Before running tests:
make check-venvThis validates:
- ✓ Virtual environment exists (
.venv/) - ✓ Package is installed in editable mode
- ✓ You're using the venv's Python (warns if not activated)
If make check-venv shows problems:
# Quick fix: reinstall in editable mode
.venv/bin/pip install -e . --no-deps
# Full reset: recreate environment
make sync-deps# Run full test suite (automatically checks venv first)
make test
# If environment is out of sync, you'll see:
# ❌ Environment out of sync - package not in editable mode
# 💡 Quick fix: Run one of these commands:
# make sync-deps # Recommended: full sync
# make test AUTO_FIX=1 # Auto-fix and continue
# .venv/bin/pip install -e . --no-deps # Manual fix
# Option 1: Fix manually then re-run
make sync-deps
make test
# Option 2: Auto-fix in one command
make test AUTO_FIX=1
# Run specific tests
.venv/bin/python3 -m pytest tests/test_specific.py -v
# Run with coverage
make coverageHow it works:
make testautomatically runscheck-venvfirst- If out of sync, it fails with clear fix instructions
- You either run
make sync-depsor useAUTO_FIX=1to auto-fix - Tests won't run until environment is valid
Important: Always use .venv/bin/python3 or activate the venv:
source .venv/bin/activate # Now 'python3' uses venv
make test # Uses venv automaticallyGlassAlpha is a compliance tool that must produce byte-identical outputs. All code changes must preserve determinism.
Always source the determinism environment before running tests:
source scripts/setup-determinism-env.sh
pytest tests/- Never use parallel testing: No
pytest -norpytest-xdist - Always set seeds: Any randomness must use
glassalpha.utils.seeds.get_rng() - Single-threaded only: All BLAS/LAPACK/OpenMP operations run single-threaded
- No system time: Use
SOURCE_DATE_EPOCHfor timestamps - Fixed locale: All tests run in
Clocale
Before pushing changes:
# Quick check (30 seconds)
./scripts/test_determinism.sh quick
# Full check (5 minutes)
./scripts/test_determinism.sh fullIf determinism breaks, check:
- Config has
reproducibility.strict: true - No unseeded random operations
- Thread counts are controlled
GlassAlpha's approach combines best practices from major Python projects:
pip install -e ".[dev]" # Editable mode
pip install -r requirements/dev.txt # Pin versionsconstraints/
├── dev-requirements.txt # Frozen development versions
├── ci-requirements.txt # CI-specific pins
└── docs-requirements.txt # Documentation builds
make test # Automatically checks venv
make check-venv # Manual validation
make sync-deps # Auto-sync environmentKey Innovation: We add a check-venv step that runs before every test, catching environment drift immediately instead of debugging mysterious failures later.
# Just keep your environment in sync
.venv/bin/pip install -e . --no-deps # After pulling changesWhen adding or updating dependencies:
# 1. Update pyproject.toml
# 2. Reinstall
.venv/bin/pip install -e ".[dev,all]"
# 3. Freeze current versions
make freeze-deps
# 4. Commit both files
git add pyproject.toml constraints/dev-requirements.txt
git commit -m "Update dependencies: added X, upgraded Y"This creates a single source of truth for dependency versions that:
- Works locally (via editable install)
- Works in CI (via constraints file)
- Works for contributors (via
make dev-setup)
Before committing:
make checkThis runs:
- ✓ Smoke test (validates critical contracts)
- ✓ Workflow validation (YAML syntax + action versions)
- ✓ Sigstore check (signing process validation)
- ✓ Packaging check (MANIFEST.in completeness)
- ✓ Determinism check (CI compatibility)
- ✓ Environment check (
glassalpha doctor) - ✓ Documentation check (CLI docs up to date)
Installed automatically by make dev-setup:
Pre-commit: Runs smoke test only if fragile areas changed Pre-push: Always runs smoke test to catch regressions
Q: How does CI handle environment sync?
A: CI automatically validates on every run:
# In .github/workflows/test-with-sync.yml
- name: Install dependencies
run: pip install -e ".[dev,all]" # Always editable mode
- name: Validate environment sync
run: python scripts/sync-deps.py --check # Fails if out of syncKey differences:
- Local: You might have stale installs →
make testcatches it - CI: Fresh install every time → Should always be in sync
Q: What if CI environment is out of sync?
A: CI will FAIL with clear error:
❌ Environment out of sync in CI
This should not happen - CI installs in editable mode by default
This means there's a bug in the CI workflow (not your code). File an issue!
Q: Do I need to manually update CI?
A: No! CI auto-syncs on every run:
- Fresh environment for every CI run
pip install -e ".[dev,all]"→ always installs in editable modescripts/sync-deps.py --check→ validates it worked- If validation fails → CI fails (bug in workflow, not your code)
Your local environment matches CI by:
- Same Python version: 3.11+ (check with
python3 --version) - Same install method: Editable mode (
pip install -e .) - Same checks:
make checkruns the same validations as CI - Same test command:
make testuses same pytest invocation - Same validation: Both run
scripts/sync-deps.py --check
Cause: Environment mismatch (stale installed version)
Fix:
make check-venv # Diagnose the issue
.venv/bin/pip install -e . --no-deps # Sync with source
make test # Re-run testsCause: Package not installed or old version cached
Fix:
.venv/bin/pip install -e . --force-reinstall --no-depsCause: Not using venv's Python
Fix:
source .venv/bin/activate # Or use .venv/bin/python3 directly- Always activate venv or use
.venv/bin/python3explicitly - Run
make check-venvafter pulling changes - Run
make checkbefore committing - Run
make testbefore pushing - Use
make sync-depsif environment seems broken
Problem: Developers waste hours debugging issues caused by:
- Stale installed packages
- Different Python versions
- Missing dependencies
- Environment drift
Solution: Automated validation that catches these issues immediately with clear fix instructions.
Result:
- ✅ Tests are reliable
- ✅ CI matches local
- ✅ New contributors onboard fast
- ✅ No mysterious environment bugs
If you encounter issues with the development environment:
- Run
make check-venvto diagnose - Try
make sync-depsto reset - Check this guide for common solutions
- Open an issue with the output of
glassalpha doctor