Skip to content

Python Build System#302

Draft
CavRiley wants to merge 7 commits intoInsightSoftwareConsortium:mainfrom
BRAINSia:python-build-system
Draft

Python Build System#302
CavRiley wants to merge 7 commits intoInsightSoftwareConsortium:mainfrom
BRAINSia:python-build-system

Conversation

@CavRiley
Copy link
Copy Markdown

Python-based build system for generating Python wheels

Supersedes @hjmjohnson draft PR #299

This refactoring transitions build logic entirely to Python scripts while maintaining the shell script entry points for cached builds either locally or in the GitHub Action environment. A couple of the build improvements are outlined below:

  1. Consolidated build dependencies into pixi environments. A pixi.toml manifest replaces requirements-dev.txt and implicit system tool assumptions. All dependencies are specified with version constraints and composed into per-platform, per-Python-version environments (e.g. manylinux228-py310, macosx-py311).
  2. Uses a Python class hierarchy: BuildPythonInstanceBase defines the shared build pipeline, with LinuxBuildPythonInstance, MacOSBuildPythonInstance, and WindowsBuildPythonInstance overriding only platform-specific behavior (wheel repair, environment setup, tarball creation).

Some developer improvements:

  1. pre-commit hooks, linters/formatters/shellchecks (run locally and via GitHub actions)
  2. GitHub actions workflow for generating sphinx documentation
  3. Issue/PR templates
  4. Moves to conventional commits (this can be changed if the format should not be changed)

Migration Guide for GitHub Actions

To migrate the GitHub actions work flows to use this new build infrastructure, new caches builds need to be created with this build system (build paths and names changed to be consistent across environment).

Once the cache files are uploaded to the ITKPythonBuilds repository the actions can use the specific Git tag the caches are uploaded under. To use this infrastructure you would also need to specify the branch this addition would go under. For example:

uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@main
    with:
      itk-wheel-tag: 'v6.0b02.post1' # an example tag
      itk-python-package-tag: python-build-system # an example branch

Backwards compatibility

  • The *-download-cache-and-build-module-wheels.sh / .ps1 entry points are preserved so existing remote module CI configurations and ITKRemoteModuleBuildTestPackageAction workflows continue to work without modification (assuming the build uses the new cache)
  • Environment variables (ITK_PACKAGE_VERSION, CMAKE_OPTIONS, ITK_MODULE_PREQ, MANYLINUX_VERSION, etc.) remain the same and are still accepted.

I'd appreciate any feedback you could provide regarding improvements or issues

CavRiley and others added 7 commits March 28, 2026 21:05
…Python scripts

Replaces the primary build orchestration layer with a Python-based system.
Adds core abstractions including BuildManager for step-wise build
persistence/resumption, CMakeArgumentBuilder for managing CMake definitions,
cross-platform venv utilities, subprocess helpers, and pixi environment
integration. Establishes platform-specific base classes that Linux, macOS,
and Windows implementations extend. Restructures CMake layout into modular
BuildWheelsSupport and SuperbuildSupport components. Shell scripts remain
where still required.

Co-authored-by: Hans J. Johnson <hans-johnson@uiowa.edu>
…d Windows

Implements platform build scripts using the new Python infrastructure.
Linux/manylinux builds use dockcross with auditwheel for manylinux
compliance. macOS builds integrate delocate and respect
MACOSX_DEPLOYMENT_TARGET. Windows builds use delvewheel for wheel
repair. Removes legacy shell scripts superseded by the new Python
implementations.

Co-authored-by: Hans J. Johnson <hans-johnson@uiowa.edu>
Adds make_tarballs.sh and integrates tarball generation logic into
build_python_instance_base.py. Supports creating, downloading, and reusing
ITK build caches across Linux, macOS, and Windows, including manylinux
tarball support, arch-specific naming, and a --build-itk-tarball-cache
CLI option. Adds make_windows_zip.ps1 for streamlined Windows wheel
packaging and zip creation.
… 3.9

Removes unused and outdated shell scripts and legacy build utilities
superseded by the new Python build system. Adds pre-commit hooks with
linting applied across the codebase. Drops Python 3.9 support as it is
EOL. Includes README and documentation updates for the new build workflow.
@CavRiley CavRiley force-pushed the python-build-system branch from 182e8a5 to 4aa0abb Compare March 29, 2026 02:05
@CavRiley
Copy link
Copy Markdown
Author

Also may close #127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant