From 403bab2a43e2969d980ceaa88c6d282ca803853d Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Tue, 24 Nov 2026 12:53:19 -0600 Subject: [PATCH] COMP: Remove make_tarballs.sh and make_windows_zip.ps1 (#310 tier 1) Both wrap build_wheels.py --build-itk-tarball-cache, which `pixi run release-wheels` now passes for every target. At d1e7d0d they were referenced only by each other, README.md, docs/Build_ITK_Python_packages.rst, and a .gitignore comment; no test, pixi task, or workflow calls them. The docs now point at release-wheels and say where it places caches, including the macOS build root needed to match the CI path. install-pixi.ps1 stays ignored for windows-download-cache-and-build-module-wheels.ps1. pytest tests/: 489 passed. --- .gitignore | 5 +- README.md | 29 ++--- docs/Build_ITK_Python_packages.rst | 23 ++-- scripts/make_tarballs.sh | 111 ------------------ scripts/make_windows_zip.ps1 | 174 ----------------------------- 5 files changed, 27 insertions(+), 315 deletions(-) delete mode 100755 scripts/make_tarballs.sh delete mode 100644 scripts/make_windows_zip.ps1 diff --git a/.gitignore b/.gitignore index 3d1c0542..26922133 100644 --- a/.gitignore +++ b/.gitignore @@ -83,7 +83,6 @@ docs/_build .pixi/* !.pixi/config.toml -# pixi installer that the Windows entry-point scripts fetch into the -# working directory (make_windows_zip.ps1, -# windows-download-cache-and-build-module-wheels.ps1) +# pixi installer that windows-download-cache-and-build-module-wheels.ps1 +# fetches into the working directory install-pixi.ps1 diff --git a/README.md b/README.md index be1df5d6..72940797 100644 --- a/README.md +++ b/README.md @@ -386,19 +386,17 @@ To see how to build ITK Python Build Caches, see this section: #### GitHub Compatible Caches -To build the caches compatible with GitHub Actions CI and the ITKPythonBuilds repository. You can run: - -On Linux and macOS systems +`release-wheels` builds the caches compatible with GitHub Actions CI and the +ITKPythonBuilds repository alongside the wheels: it passes +`--build-itk-tarball-cache` to `build_wheels.py` for every target. ```bash -bash scripts/make_tarballs.sh # py311 (optionally add specific version of Python) +pixi run release-wheels v6.0b03 ``` -On Windows systems - -```powershell -.\scripts\make_windows_zip.ps1 # py311 (optionally add specific version of Python) -``` +POSIX builds write `dist/ITKPythonBuilds--.tar.zst` under the +build root (`scripts/wheel_packaging.py`); Windows writes +`ITKPythonBuilds-windows.zip` in the build root. > [!IMPORTANT] > Build caches embed absolute paths. If you extract a tarball to a different @@ -410,11 +408,14 @@ On Windows systems > | macOS | `/Users/svc-dashboard/D/P/ITKPythonPackage-build` | > | Windows | `C:\BDR` | > -> The scripts above set these for you. **`build_wheels.py` does not**: its -> default build root is `/../ITKPythonPackage-build`, which matches the -> convention only on Windows. A cache built by calling `build_wheels.py` -> directly therefore needs `--build-dir-root` set to the path in the table, or -> it will not be usable by the reusable workflow. Check a finished cache with: +> `release-wheels` uses the manylinux and Windows paths by default. On macOS +> its build root is `/../ITKPythonPackage-build`, so clone the +> repository at `/Users/svc-dashboard/D/P/ITKPythonPackage` or pass +> `--build-root /Users/svc-dashboard/D/P/ITKPythonPackage-build`. +> `build_wheels.py` called directly defaults to `C:\BDR` on Windows and to +> `/../ITKPythonPackage-build` elsewhere, so a macOS cache built that way +> needs `--build-dir-root` set to the path in the table, or it will not be +> usable by the reusable workflow. Check a finished cache with: > > ```bash > tar -xOf .tar ITKPythonPackage-build/build/ITK-support-bld/CMakeCache.txt \ diff --git a/docs/Build_ITK_Python_packages.rst b/docs/Build_ITK_Python_packages.rst index c16468cd..84a08768 100644 --- a/docs/Build_ITK_Python_packages.rst +++ b/docs/Build_ITK_Python_packages.rst @@ -295,21 +295,16 @@ artifacts) so that external module builds can skip the costly ITK compilation st These are the same caches distributed via `ITKPythonBuilds `_ releases. -By default these scripts build for Python 3.11 but you can optionally add a specific version to build for - -Linux / macOS: +``release-wheels`` builds a cache for every target it builds, by passing +``--build-itk-tarball-cache`` to ``build_wheels.py``: .. code-block:: bash - ITK_GIT_TAG=v6.0b01 - bash scripts/make_tarballs.sh py311 - -Windows (PowerShell): - -.. code-block:: powershell + pixi run release-wheels v6.0b01 - $env:ITK_GIT_TAG = "v6.0b01" - .\scripts\make_windows_zip.ps1 py311 +POSIX builds write ``dist/ITKPythonBuilds--.tar.zst`` under the +build root (``scripts/wheel_packaging.py``); Windows writes +``ITKPythonBuilds-windows.zip`` in the build root. Or via ``build_wheels.py`` directly: @@ -329,8 +324,10 @@ Or via ``build_wheels.py`` directly: - **macOS**: ``/Users/svc-dashboard/D/P/ITKPythonPackage-build`` - **Windows**: ``C:\BDR`` - The ``make_tarballs.sh`` and ``make_windows_zip.ps1`` scripts enforce these - paths automatically. + ``release-wheels`` uses the manylinux and Windows paths by default. On + macOS, clone the repository at ``/Users/svc-dashboard/D/P/ITKPythonPackage`` + or pass ``--build-root /Users/svc-dashboard/D/P/ITKPythonPackage-build`` + (``--build-dir-root`` for ``build_wheels.py``). Output Artifacts diff --git a/scripts/make_tarballs.sh b/scripts/make_tarballs.sh deleted file mode 100755 index 0d887c64..00000000 --- a/scripts/make_tarballs.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -# NOTES: Building tarballs requires specific pathing for supporting github CI -# workflows - -script_dir=$( - cd "$(dirname "$0")" || exit 1 - pwd -) -_ipp_dir=$(dirname "${script_dir}") - -# If args are given, use them. Otherwise use default python environments -pyenvs=("${@:-py311}") - -# Otherwise process mac and linux based on uname - -# Need to explicitly request to --build-itk-tarball-cache -BUILD_WHEELS_EXTRA_FLAGS=("--build-itk-tarball-cache") -if [ -z "${ITK_GIT_TAG}" ]; then - DEFAULT_ITK_GIT_TAG=main - echo "=============================================================================" - echo "=============================================================================" - for _ in x x x x x x x x x x x x x x x x x x x x x x x x x x x x x; do - echo "===== WARNING: ITK_GIT_TAG not set, so defaulting to ${DEFAULT_ITK_GIT_TAG}" - done - echo "=============================================================================" - echo "=============================================================================" -fi -ITK_GIT_TAG=${ITK_GIT_TAG:=${DEFAULT_ITK_GIT_TAG}} - -## -- -# -- -# -- -# -- -# Short circuit builds to use dockcross if MANYLINUX_VERSION is requested -if [ -n "${MANYLINUX_VERSION}" ]; then - BUILD_WHEELS_EXTRA_FLAGS="${BUILD_WHEELS_EXTRA_FLAGS[*]}" \ - ITK_GIT_TAG=${ITK_GIT_TAG} \ - MANYLINUX_VERSION=${MANYLINUX_VERSION} \ - bash "${_ipp_dir}/scripts/dockcross-manylinux-build-wheels.sh" \ - "${pyenvs[@]}" - exit $? -fi - -## -- -# -- -# -- -# -- -case "$(uname -s)" in -Darwin) - PLATFORM_PREFIX="macosx" - DASHBOARD_BUILD_DIRECTORY=${DASHBOARD_BUILD_DIRECTORY:=/Users/svc-dashboard/D/P} - ;; -Linux) - PLATFORM_PREFIX="linux" - DASHBOARD_BUILD_DIRECTORY=${DASHBOARD_BUILD_DIRECTORY:=/work} - ;; - # POSIX build env NOT SUPPORTED for windows, Needs to be done in a .ps1 shell - # MINGW*|MSYS*|CYGWIN*) - # PLATFORM_PREFIX="windows" - # DASHBOARD_BUILD_DIRECTORY="C:\P" - # ;; -*) - echo "Unsupported platform: $(uname -s)" - exit 1 - ;; -esac - -# Required environment variables -required_vars=( - ITK_GIT_TAG - PLATFORM_PREFIX - DASHBOARD_BUILD_DIRECTORY - -) - -# shellcheck source=/dev/null -source "${script_dir}/require_env_vars.sh" -require_env_vars "${required_vars[@]}" - -if [ ! -d "${DASHBOARD_BUILD_DIRECTORY}" ]; then - # This is the expected directory for the cache, It may require creation with administrator credentials - mkdir -p "${DASHBOARD_BUILD_DIRECTORY}" -fi -if [ "${script_dir}" != "${DASHBOARD_BUILD_DIRECTORY}/ITKPythonPackage/scripts" ]; then - echo "ERROR: Github CI requires rigid directory structure, you may substitute the ITKPythonPackage organization if testing" - echo " RUN: cd ${DASHBOARD_BUILD_DIRECTORY}" - echo " RUN: git clone git@github.com:${ITKPYTHONPACKAGE_ORG}/ITKPythonPackage.git ${DASHBOARD_BUILD_DIRECTORY}/ITKPythonPackage" - echo " FOR DEVELOPMENT RUN: git checkout python-build-system" - echo " RUN: ${DASHBOARD_BUILD_DIRECTORY}/ITKPythonPackage/scripts/make_tarballs.sh" - exit 1 -fi - -export PIXI_HOME=${DASHBOARD_BUILD_DIRECTORY}/.pixi -if [ ! -f "${PIXI_HOME}/bin/pixi" ]; then - #PIXI INSTALL - if [ ! -f "${PIXI_HOME}/bin/pixi" ]; then - curl -fsSL https://pixi.sh/install.sh | sh - export PATH="${PIXI_HOME}/bin:$PATH" - fi -fi - -for pyenv in "${pyenvs[@]}"; do - cd "${DASHBOARD_BUILD_DIRECTORY}/ITKPythonPackage" || exit - "${PIXI_HOME}/bin/pixi" run -e "${PLATFORM_PREFIX}-${pyenv}" \ - python3 "${DASHBOARD_BUILD_DIRECTORY}/ITKPythonPackage/scripts/build_wheels.py" \ - --platform-env "${PLATFORM_PREFIX}-${pyenv}" \ - --build-dir-root "${DASHBOARD_BUILD_DIRECTORY}/ITKPythonPackage-build" \ - --itk-source-dir "${DASHBOARD_BUILD_DIRECTORY}/ITKPythonPackage-build/ITK" \ - --itk-git-tag "${ITK_GIT_TAG}" \ - "${BUILD_WHEELS_EXTRA_FLAGS[@]}" -done diff --git a/scripts/make_windows_zip.ps1 b/scripts/make_windows_zip.ps1 deleted file mode 100644 index 744fcaad..00000000 --- a/scripts/make_windows_zip.ps1 +++ /dev/null @@ -1,174 +0,0 @@ -######################################################################## -# Build ITK Python wheel tarballs (build cache) on Windows. -# -# This is the Windows PowerShell equivalent of make_tarballs.sh. -# POSIX shell is not supported for this workflow on Windows. -# -# This script builds the ITK core cache only; it has no knowledge of -# external modules. Module-specific flags (--module-source-dir, -# --module-dependencies-root-dir, --itk-module-deps, --lib-paths) are -# intentionally absent; they belong only in the module wheel build script. -# -# Directory names are intentionally kept short to avoid Windows MAX_PATH -# issues during deep CMake/compiler builds. Everything lives under one -# root directory (C:\BDR) so no build artifacts are scattered at C:\: -# ITKPythonPackage -> C:\BDR\IPP (scripts clone) -# ITK source -> C:\BDR\ITK (ITK git checkout) -# build root -> C:\BDR (build_wheels.py root; cached build lands at C:\BDR\build\ITK-windows-...) -# -# This script MUST be run from the canonical location: -# C:\BDR\IPP\scripts\make_tarballs.ps1 -# -# Typical usage: -# > $env:ITK_GIT_TAG = "v6.0rc01" -# > .\make_tarballs.ps1 -# -# Restrict to specific python versions by passing them as arguments: -# > .\make_tarballs.ps1 py311 -# -# ----------------------------------------------------------------------- -# Environment variables: -# -# `$env:ITK_GIT_TAG` -# ITK git tag to build from. Falls back to main with loud warnings -# if unset, matching the bash script behavior. -# -######################################################################## -param ( - [Parameter(ValueFromRemainingArguments)] - [string[]]$pyenvs -) - -Set-StrictMode -Version Latest -$ErrorActionPreference = "Stop" - -# Resolve python environments -if (-not $pyenvs -or $pyenvs.Count -eq 0) { - $pyenvs = @("py311") -} -echo "Building for python environments: $($pyenvs -join ', ')" - -# Resolve ITK_GIT_TAG, with a loud warning if unset, matching bash behavior -$DEFAULT_ITK_GIT_TAG = "main" -if (-not $env:ITK_GIT_TAG) { - $warningLine = "===== WARNING: ITK_GIT_TAG not set, so defaulting to $DEFAULT_ITK_GIT_TAG" - echo "=============================================================================" - 1..29 | ForEach-Object { echo $warningLine } - echo "=============================================================================" - $env:ITK_GIT_TAG = $DEFAULT_ITK_GIT_TAG -} -$ITK_GIT_TAG = $env:ITK_GIT_TAG -echo "ITK_GIT_TAG : $ITK_GIT_TAG" - -# Compute paths from this script's location. -# Everything is contained under one build root to keep all build artifacts -# in one place and avoid spreading directories across the drive root. The -# root is the directory holding the IPP checkout, so the same layout works -# on any drive: C:\BDR on CI, D:\BDR on a build box with a separate drive. -# A cache is only consumable at the root it was built under, since the ITK -# build tree records absolute paths; CI extracts at C:\BDR. -# -# \ <- $BDR (single root for all build content) -# \IPP\scripts\ <- $ScriptsDir (this file) -# \IPP\ <- $IPPDir (ITKPythonPackage clone) -# \ITK\ <- $ItkSourceDir (ITK git checkout) -# \ <- $BuildDirRoot (build root; cached build lands at \build\ITK-windows-...) -# \.pixi\ <- pixi home -$ScriptsDir = Split-Path -Parent $MyInvocation.MyCommand.Path -$IPPDir = Split-Path -Parent $ScriptsDir -$BDR = Split-Path -Parent $IPPDir -$BuildScript = Join-Path $ScriptsDir "build_wheels.py" -$ItkSourceDir = Join-Path $BDR "ITK" -$BuildDirRoot = $BDR - -echo "BDR : $BDR" -echo "IPPDir : $IPPDir" -echo "ScriptsDir : $ScriptsDir" -echo "ItkSourceDir : $ItkSourceDir" -echo "BuildDirRoot : $BuildDirRoot" - -# Validate the layout: the checkout must be named IPP directly under the -# root, because the cache and CI both assume \IPP. -$ExpectedScriptsDir = Join-Path $BDR "IPP\scripts" -if ($ScriptsDir -ne $ExpectedScriptsDir) { - Write-Error @" -ERROR: GitHub CI requires a rigid directory structure. -Script found at : $ScriptsDir -Expected location: $ExpectedScriptsDir - - RUN: cd $BDR - RUN: git clone git@github.com:/ITKPythonPackage.git $BDR\IPP - FOR DEVELOPMENT: git checkout python-build-system - RUN: $ExpectedScriptsDir\make_windows_zip.ps1 -"@ - exit 1 -} - -if (-not (Test-Path -LiteralPath $BuildScript)) { - throw "build_wheels.py not found at: $BuildScript" -} - -# Create BDR if it doesn't exist -# (may require administrator credentials on a fresh machine) -if (-not (Test-Path -LiteralPath $BDR)) { - echo "Creating directory: $BDR" - New-Item -ItemType Directory -Path $BDR -Force | Out-Null -} - -# Install pixi if not already present. -# Python, Doxygen, and all build tools are provided by the pixi environment. -$env:PIXI_HOME = "$BDR\.pixi" -if (-not (Test-Path "$env:PIXI_HOME\bin\pixi.exe")) { - echo "Installing pixi..." - # Invoke-WebRequest has no timeout by default, so an unreachable pixi.sh - # hung the build indefinitely. Bound it, and fall back to the release - # binary on GitHub, which is what the installer script fetches anyway. - try { - Invoke-WebRequest -Uri "https://pixi.sh/install.ps1" -OutFile "install-pixi.ps1" -TimeoutSec 60 - powershell -ExecutionPolicy Bypass -File "install-pixi.ps1" - } catch { - echo "pixi.sh installer unavailable ($($_.Exception.Message)); fetching the release binary from GitHub" - New-Item -ItemType Directory -Path "$env:PIXI_HOME\bin" -Force | Out-Null - Invoke-WebRequest -Uri "https://github.com/prefix-dev/pixi/releases/latest/download/pixi-x86_64-pc-windows-msvc.exe" ` - -OutFile "$env:PIXI_HOME\bin\pixi.exe" -TimeoutSec 300 - } - if (-not (Test-Path "$env:PIXI_HOME\bin\pixi.exe")) { - throw "pixi was not installed at $env:PIXI_HOME\bin\pixi.exe" - } -} -$env:Path = "$env:PIXI_HOME\bin;$env:Path" - -# Build each requested python environment. -# Push-Location/finally ensures we always restore the caller's directory. -Push-Location $IPPDir -try { - foreach ($pyenv in $pyenvs) { - # Normalize any of: py311 / py3.11 / cp311 / 3.11 -> py311 - $pySquashed = $pyenv -replace 'py|cp|\.', '' - $pyenv = "py$pySquashed" - $platformEnv = "windows-$pyenv" - - echo "" - echo "========================================================" - echo "Building cache for platform env: $platformEnv" - echo "========================================================" - - pixi run -e $platformEnv python $BuildScript ` - --platform-env $platformEnv ` - --build-itk-tarball-cache ` - --build-dir-root $BuildDirRoot ` - --itk-source-dir $ItkSourceDir ` - --itk-git-tag $ITK_GIT_TAG ` - --no-use-ccache - - if ($LASTEXITCODE -ne 0) { - throw "build_wheels.py failed for $platformEnv (exit code $LASTEXITCODE)" - } - } -} -finally { - Pop-Location -} - -echo "" -echo "All tarball builds completed successfully."