ModuleBuilder (abstract base)
├── PythonBuilder (abstract, extends ModuleBuilder)
│ └── Cpython (concrete implementation in cpython.py)
└── External modules (in external/xcpython.py, xtkinter.py)
├── Bdb, Bzip2, Gdbm, LibFFI, Mpdec, Openssl, Readline
├── Sqlite, Uuid, Xz, Zlib, Zstd, TkInter
BuildSetup (coordinates overall compilation)
├── BuildContext (handles isolation hacks on macOS)
├── Folders (manages build directory structure)
└── ModuleCollection (manages module selection and dependencies)
PPG (Global state singleton)
├── config: Config (YAML configuration)
├── target: PlatformId (target OS/arch)
├── cpython: CPythonFamily (available versions)
└── families: dict (extensible family support)
Config
├── Folders (build/dist/sources/logs directories)
├── target platform detection
├── YAML config merging (platform-specific overrides)
PythonInspector
├── Inspect Python installation for portability
├── LibAutoCorrect (rewrite paths to be relative)
└── Report system and shared lib detection
Tracker/Trackable
├── Categorizes found issues/objects by type
└── Provides detailed reports
-
Hierarchical Module Building: External modules are compiled first, then Python itself, using the same build framework.
-
Environment Variable Injection:
xenv_*methods dynamically provide environment variables (CPATH, LDFLAGS, PATH, etc.) for compilation. -
Platform Abstraction:
PPG.target(PlatformId) encapsulates platform logic. Compile methods named_do_<platform>_compile()dispatch to platform-specific implementations. -
Configuration Precedence: YAML config supports platform-specific overrides (windows.ext, macos.env, etc.). Most specific setting wins.
-
Folder Masking (macOS): On macOS,
/usr/localis temporarily masked with a RAM disk to prevent accidental dynamic linking. -
Build Isolation: All external modules compiled to a shared
build/deps/folder, Python finds them via CPATH/LDFLAGS. -
Lazy Version Fetching:
VersionFamilycaches available versions, fetching from python.org on first access. -
Telltale Detection: Modules check for marker files (
m_telltale) to determine if they're already available on the system (as shared libs). -
Log Aggregation: Each module logs to a separate file (
01-openssl.log,02-cpython.log, etc.) underbuild/logs/.
tests.yml (main branch & PRs):
- Matrix test on py3.10, 3.11, 3.12, 3.13, 3.14
- Runs:
uvx --with tox-uv tox -e py - Coverage upload to coveralls.io (parallel, then finish)
- Linter job: docs + style checks on 3.14
release.yml (version tags v*):
- Triggers on
v[0-9]*tags - Runs all tests + docs + style
- Builds distribution with
uv build - Publishes to PyPI via trusted publishing (OIDC)