|
| 1 | +## Architecture |
| 2 | + |
| 3 | +### Core Classes Hierarchy |
| 4 | + |
| 5 | +``` |
| 6 | +ModuleBuilder (abstract base) |
| 7 | +├── PythonBuilder (abstract, extends ModuleBuilder) |
| 8 | +│ └── Cpython (concrete implementation in cpython.py) |
| 9 | +└── External modules (in external/xcpython.py, xtkinter.py) |
| 10 | + ├── Bdb, Bzip2, Gdbm, LibFFI, Mpdec, Openssl, Readline |
| 11 | + ├── Sqlite, Uuid, Xz, Zlib, Zstd, TkInter |
| 12 | +
|
| 13 | +BuildSetup (coordinates overall compilation) |
| 14 | +├── BuildContext (handles isolation hacks on macOS) |
| 15 | +├── Folders (manages build directory structure) |
| 16 | +└── ModuleCollection (manages module selection and dependencies) |
| 17 | +
|
| 18 | +PPG (Global state singleton) |
| 19 | +├── config: Config (YAML configuration) |
| 20 | +├── target: PlatformId (target OS/arch) |
| 21 | +├── cpython: CPythonFamily (available versions) |
| 22 | +└── families: dict (extensible family support) |
| 23 | +
|
| 24 | +Config |
| 25 | +├── Folders (build/dist/sources/logs directories) |
| 26 | +├── target platform detection |
| 27 | +├── YAML config merging (platform-specific overrides) |
| 28 | +
|
| 29 | +PythonInspector |
| 30 | +├── Inspect Python installation for portability |
| 31 | +├── LibAutoCorrect (rewrite paths to be relative) |
| 32 | +└── Report system and shared lib detection |
| 33 | +
|
| 34 | +Tracker/Trackable |
| 35 | +├── Categorizes found issues/objects by type |
| 36 | +└── Provides detailed reports |
| 37 | +``` |
| 38 | + |
| 39 | +### Key Design Patterns |
| 40 | + |
| 41 | +1. **Hierarchical Module Building**: External modules are compiled first, then Python itself, using the same build framework. |
| 42 | + |
| 43 | +2. **Environment Variable Injection**: `xenv_*` methods dynamically provide environment variables (CPATH, LDFLAGS, PATH, etc.) for compilation. |
| 44 | + |
| 45 | +3. **Platform Abstraction**: `PPG.target` (PlatformId) encapsulates platform logic. Compile methods named `_do_<platform>_compile()` dispatch to platform-specific implementations. |
| 46 | + |
| 47 | +4. **Configuration Precedence**: YAML config supports platform-specific overrides (windows.ext, macos.env, etc.). Most specific setting wins. |
| 48 | + |
| 49 | +5. **Folder Masking (macOS)**: On macOS, `/usr/local` is temporarily masked with a RAM disk to prevent accidental dynamic linking. |
| 50 | + |
| 51 | +6. **Build Isolation**: All external modules compiled to a shared `build/deps/` folder, Python finds them via CPATH/LDFLAGS. |
| 52 | + |
| 53 | +7. **Lazy Version Fetching**: `VersionFamily` caches available versions, fetching from python.org on first access. |
| 54 | + |
| 55 | +8. **Telltale Detection**: Modules check for marker files (`m_telltale`) to determine if they're already available on the system (as shared libs). |
| 56 | + |
| 57 | +9. **Log Aggregation**: Each module logs to a separate file (`01-openssl.log`, `02-cpython.log`, etc.) under `build/logs/`. |
| 58 | + |
| 59 | + |
| 60 | +## CI/CD |
| 61 | + |
| 62 | +### GitHub Actions |
| 63 | + |
| 64 | +**tests.yml** (main branch & PRs): |
| 65 | +- Matrix test on py3.10, 3.11, 3.12, 3.13, 3.14 |
| 66 | +- Runs: `uvx --with tox-uv tox -e py` |
| 67 | +- Coverage upload to coveralls.io (parallel, then finish) |
| 68 | +- Linter job: docs + style checks on 3.14 |
| 69 | + |
| 70 | +**release.yml** (version tags v*): |
| 71 | +- Triggers on `v[0-9]*` tags |
| 72 | +- Runs all tests + docs + style |
| 73 | +- Builds distribution with `uv build` |
| 74 | +- Publishes to PyPI via trusted publishing (OIDC) |
0 commit comments