|
| 1 | +# Contributing to managed-python |
| 2 | + |
| 3 | +## Architecture |
| 4 | + |
| 5 | +Installation is split into two phases: |
| 6 | + |
| 7 | +```text |
| 8 | +install.sh / install.ps1 → setup.py → configured prefix |
| 9 | + (bootstrap: uv + venv) (configure: everything else) |
| 10 | +``` |
| 11 | + |
| 12 | +**Bootstrap scripts** (`install.sh`, `install.ps1`) are minimal — they exist only because |
| 13 | +downloading a binary and creating a venv require platform-specific shell syntax before Python is |
| 14 | +available. Once the venv exists, control passes immediately to `setup.py`. |
| 15 | + |
| 16 | +**`setup.py`** runs inside the freshly-created venv and handles all logic that would otherwise be |
| 17 | +duplicated across bash and PowerShell: bin/ wrappers, env.sh, env.ps1, distro.toml copy, shell |
| 18 | +profile update. It is pure stdlib with no external dependencies. |
| 19 | + |
| 20 | +## What Goes Where |
| 21 | + |
| 22 | +| Concern | Script | |
| 23 | +|---------|--------| |
| 24 | +| Download uv binary | `install.sh` / `install.ps1` | |
| 25 | +| Create Python venv | `install.sh` / `install.ps1` | |
| 26 | +| Write `env.sh` / `env.ps1` / `env.bat` | `setup.py` | |
| 27 | +| Create `bin/` wrappers / symlinks | `setup.py` | |
| 28 | +| PATH detection logic | `setup.py` | |
| 29 | +| Shell profile update | `setup.py` | |
| 30 | +| Output: step headers, completion box | `setup.py` | |
| 31 | +| Record install options | `setup.py` → installed `distro.toml` | |
| 32 | + |
| 33 | +## Design Principles |
| 34 | + |
| 35 | +### setup.py is stdlib-only, always |
| 36 | + |
| 37 | +`setup.py` must never import anything outside the Python standard library. It runs inside a |
| 38 | +freshly-created venv that has no packages installed. Any helper logic that might seem to warrant a |
| 39 | +library (TOML parsing, path manipulation, HTTP) must be implemented with stdlib primitives. |
| 40 | + |
| 41 | +The moment `setup.py` gains a dependency, bootstrap becomes circular. |
| 42 | + |
| 43 | +### Shell scripts do the minimum necessary |
| 44 | + |
| 45 | +`install.sh` and `install.ps1` exist for exactly two reasons: (1) downloading a binary requires |
| 46 | +curl/wget or Invoke-WebRequest, and (2) creating a venv requires the uv binary that was just |
| 47 | +downloaded. No PATH logic, no env file generation, and no output formatting beyond simple progress |
| 48 | +lines belongs in the shell scripts. |
| 49 | + |
| 50 | +### Env vars are the contract, PATH is a convenience |
| 51 | + |
| 52 | +The env var names passed via `--uv-env` and `--python-env` are always exported unconditionally. |
| 53 | +Scripts should reference these vars directly and never rely on `python` or `uv` being on PATH. PATH |
| 54 | +is only modified in `env.sh`/`env.ps1` when it won't shadow an existing system `python`/`uv`. |
| 55 | + |
| 56 | +### Non-destructive by default |
| 57 | + |
| 58 | +Never replace what the user already has without telling them. If system `python` or `uv` is found |
| 59 | +on PATH, warn before shadowing. Never silently overwrite. |
| 60 | + |
| 61 | +### Idempotency |
| 62 | + |
| 63 | +Re-running the installer with the same args is always safe. uv and venv creation are skipped when |
| 64 | +already current. All generated files are always regenerated (cheap, ensures correctness). |
| 65 | + |
| 66 | +## Versioning |
| 67 | + |
| 68 | +`distro.toml` `version` tracks the managed-python configuration itself — not Python or uv versions. |
| 69 | + |
| 70 | +- **Patch** (x.y.Z) — no-op fixes, documentation |
| 71 | +- **Minor** (x.Y.0) — new flags, new generated files, non-breaking additions |
| 72 | +- **Major** (X.0.0) — breaking layout change; users must delete the prefix and reinstall |
| 73 | + |
| 74 | +To cut a release: |
| 75 | + |
| 76 | +```bash |
| 77 | +python release.py --patch # or --minor / --major |
| 78 | +python release.py --uv-version X.Y.Z # also updates pinned checksums |
| 79 | +``` |
| 80 | + |
| 81 | +Add `--tag` to commit `distro.toml` and create a git tag in one step. |
| 82 | + |
| 83 | +## Reporting Security Issues |
| 84 | + |
| 85 | +See [SECURITY.md](SECURITY.md). |
0 commit comments