Skip to content

Commit fb3e45b

Browse files
committed
DOC: Correct README build commands and add a verification step
Every build_wheels.py example omitted the pixi environment selector, so following the README landed in the default environment and aborted. Also corrects the dockcross image tag defaults, the directory the publish script searches for tarballs, the step count, and the --cleanup description, which read as the opposite of what the flag does. Adds the expected wheel tags and how to confirm a macOS binary matches its tag.
1 parent 1074d92 commit fb3e45b

1 file changed

Lines changed: 70 additions & 10 deletions

File tree

README.md

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ For more control over your builds, skip to [The Build Process](#the-build-proces
5656

5757
### Prerequisites
5858

59-
- Python 3.11 or later
60-
- Git
61-
- Docker (for manylinux builds)
6259
- [Pixi](https://pixi.sh) package manager
60+
- Git
61+
- Docker (only for manylinux container builds)
62+
63+
Pixi supplies the Python interpreter, CMake, Ninja, and Doxygen used by the
64+
build, so no system Python 3.11 is required. Wheels target Python 3.11+.
6365

6466
**Install Pixi:**
6567
```bash
@@ -80,9 +82,25 @@ cd ITKPythonPackage
8082

8183
### Building Remote Module Wheels
8284

85+
> [!IMPORTANT]
86+
> **Always pass `-e <platform-env>` to `pixi run`.** A bare `pixi run` uses the
87+
> `default` environment, which does not carry the pinned `cmake`, `ninja`,
88+
> `doxygen`, or `git`; the build would pick up whatever is on your system
89+
> `PATH`. The build aborts immediately and names the environment you want, so
90+
> this is loud rather than silent.
91+
>
92+
> ```bash
93+
> pixi run -e macosx-py311 python3 scripts/build_wheels.py ... # correct
94+
> pixi run python3 scripts/build_wheels.py ... # aborts
95+
> ```
96+
>
97+
> To build deliberately with your own host tools instead of pixi's, set
98+
> `PIXI_ENVIRONMENT_NAME=hostsystem`. Nothing is pinned in that mode, so
99+
> reproducibility becomes yours to manage.
100+
83101
#### The Build Process
84102
85-
The build process calls `build_wheels.py`, which runs up to 7 steps:
103+
The build process calls `build_wheels.py`, which runs up to 8 steps:
86104
87105
1. Build SuperBuild support components
88106
2. Build ITK C++ with Python wrapping
@@ -91,6 +109,9 @@ The build process calls `build_wheels.py`, which runs up to 7 steps:
91109
5. Import test
92110
6. *(optional)* Build a remote module against the ITK build
93111
7. *(optional)* Build an ITK tarball cache
112+
8. *(optional)* Post-build cleanup of temporary files
113+
114+
Each completed step is recorded, so a re-run skips what already finished.
94115
95116
> [!NOTE]
96117
> When using the download-and-build scripts, steps 2–3 are skipped because the pre-built cache covers them.
@@ -109,7 +130,7 @@ Available pixi platform build environments:
109130
110131
```bash
111132
# Building ITK Python Wheels on macOS for ITK v6.0b01
112-
pixi run python3 scripts/build_wheels.py \
133+
pixi run -e macosx-py311 python3 scripts/build_wheels.py \
113134
--platform-env macosx-py311 \
114135
--itk-git-tag v6.0b01 \
115136
--no-build-itk-tarball-cache
@@ -128,13 +149,17 @@ Key options:
128149
| `--itk-module-deps` | Remote module dependencies | `Mod1@tag:Mod2@tag` |
129150
| `--module-dependencies-root-dir` | Root directory for module dependencies | `./dependencies` |
130151
| `--itk-source-dir` | Path to ITK source (use local development) | `/path/to/ITK` |
131-
| `--cleanup` | Leave temporary build files after completion | (flag) |
152+
| `--cleanup` | Keep temporary build files (skips the cleanup step) | (flag) |
153+
| `--macosx-deployment-target` | macOS floor and wheel tag; default `14.0` | `14.0` |
154+
| `--use-ccache` | Reuse compiler cache between builds | (flag) |
155+
| `--lib-paths` | Windows only: `;`-delimited dirs for delvewheel | `C:\deps\bin` |
132156
| `--no-build-itk-tarball-cache` | Skip tarball generation (default) | (flag) |
133157
| `--no-skip-itk-build` | Don't skip ITK build step (default | (flag) |
134158
| `--no-skip-itk-wheel-build` | Don't skip the ITK wheel build step (default) | (flag) |
135159
136160
137-
Run `pixi run python3 scripts/build_wheels.py --help` for the full option list.
161+
Run `pixi run -e macosx-py311 python3 scripts/build_wheels.py --help` for the
162+
full option list (substitute your own platform environment).
138163
139164
> [!NOTE]
140165
> Building ITK from source can take 1-2 hours on typical hardware. Once complete, use `--build-itk-tarball-cache` to save the result and avoid rebuilding.
@@ -194,6 +219,33 @@ Run from your module root:
194219
195220
Finished wheels are placed in `<your-module>/dist/`.
196221
222+
#### Verify what you built
223+
224+
A build that exits 0 is not proof of a usable wheel. Check the tag and, on
225+
macOS, that the binary agrees with it:
226+
227+
```bash
228+
ls dist/*.whl # expect one wheel per platform, cp311-abi3
229+
```
230+
231+
| Platform | Expected wheel tag |
232+
|---|---|
233+
| Linux x86_64 | `cp311-abi3-manylinux_2_28_x86_64` |
234+
| Linux aarch64 | `cp311-abi3-manylinux_2_28_aarch64` |
235+
| macOS arm64 | `cp311-abi3-macosx_14_0_arm64` |
236+
| Windows x86_64 | `cp311-abi3-win_amd64` |
237+
238+
On macOS the binary's minimum version must match the tag. A wheel tagged
239+
below its real minimum installs on older macOS and then fails in dyld at
240+
import, which is far harder to diagnose than a refused install:
241+
242+
```bash
243+
unzip -qq -o dist/<wheel>.whl -d /tmp/whlcheck
244+
otool -l /tmp/whlcheck/itk/*.so | awk '/minos/{print $2; exit}' # 14.0
245+
```
246+
247+
Then import it in a clean virtual environment, not in the build tree.
248+
197249
</details>
198250
199251
@@ -222,15 +274,15 @@ Key environment variables:
222274
| `ITK_GIT_TAG` | `main` | ITK branch/tag/commit to build |
223275
| `ITK_SOURCE_DIR` | `<build-root>/ITKPythonPackage-build/ITK` | Path to local ITK source (skips git clone) |
224276
| `MANYLINUX_VERSION` | `_2_28` | Manylinux standard to target |
225-
| `IMAGE_TAG` | `20250913-6ea98ba` | Dockcross image tag |
277+
| `IMAGE_TAG` | `20260203-3dfb3ff` (dockcross) or `2025.08.12-1` (quay manylinux) | Container image tag; the default depends on `CONTAINER_SOURCE` |
226278
227279
#### Linux/macOS/Windows — building ITK from source
228280
229281
Use `build_wheels.py` directly with `--itk-source-dir`:
230282
231283
```bash
232284
# Building on macOS with a specific git tag
233-
pixi run python3 scripts/build_wheels.py \
285+
pixi run -e macosx-py311 python3 scripts/build_wheels.py \
234286
--platform-env macosx-py311 \
235287
--itk-source-dir /path/to/your/ITK \
236288
--itk-git-tag my-bugfix-branch \
@@ -279,7 +331,9 @@ To publish the tarball caches to a GitHub Release, you can run:
279331
280332
> [!NOTE]
281333
> This requires the `GH_TOKEN` environment variable to be set or `gh auth login` to have been run beforehand.
282-
> Tarballs are expected in the parent directory of `--build-dir-root` (POSIX `.tar.zst`) or inside it (Windows `.zip`).
334+
> Tarballs are expected in `<build-dir-root>/dist/` (POSIX `.tar.zst`) or in
335+
> `<build-dir-root>` itself (Windows `.zip`). The parent directory is also
336+
> searched, for caches left by older builds.
283337
284338
```bash
285339
pixi run -e publish publish-tarball-cache --itk-package-version v6.0b02 --build-dir-root /path/to/build/root
@@ -384,6 +438,12 @@ for discussion related to your specific issue.
384438
If you aren't able to find an answer for your specific case, please start a discussion the
385439
[ITK Discourse forum](https://discourse.itk.org/) for help.
386440
441+
## For Contributors and Coding Agents
442+
443+
[AGENTS.md](AGENTS.md) documents the full `build_wheels.py` argument list, the
444+
wheel platform policy, and worked examples including building against an
445+
unmerged ITK pull request with custom compiler flags.
446+
387447
## Additional Information
388448
389449
- Free software: Apache Software license

0 commit comments

Comments
 (0)