Repository navigation
ENH: Replace the shell wheel build system with Python (supersedes #302) - #309
hjmjohnson wants to merge 241 commits into
Conversation
d2ec481 to
00357a9
Compare
dzenanz
left a comment
There was a problem hiding this comment.
I have taken a look. There is too much code to look carefully. I tried running locally:
M:\a\IPP>pixi run python3 "C:\Misc\ITKPythonPackage\scripts\build_wheels.py" --platform-env windows-py311 --itk-source-dir C:/Dev/ITK-git
Error: × could not find pixi.toml or pyproject.toml with tool.pixi at directory M:\a\IPP
M:\a\IPP>cd C:\Misc\ITKPythonPackage
M:\a\IPP>c:
C:\Misc\ITKPythonPackage>pixi run python3 "C:\Misc\ITKPythonPackage\scripts\build_wheels.py" --platform-env windows-py311 --itk-source-dir C:/Dev/ITK-git
WARN Encountered 2 warnings while parsing the manifest:
⚠ the `[system-requirements]` table is deprecated in favor of virtual packages on `platforms`
╭─[C:\Misc\ITKPythonPackage\pixi.toml:82:1]
81 │
82 │ ╭─▶ [feature.manylinux228-build.system-requirements]
83 │ │ linux = "5.4"
84 │ ├─▶ libc = { family = "glibc", version = "2.28" }
· ╰──── declare these on the `platforms` entries instead
85 │
╰────
help: e.g. platforms = [{ platform = "linux-64", cuda = "12" }]
⚠ the `[system-requirements]` table is deprecated in favor of virtual packages on `platforms`
╭─[C:\Misc\ITKPythonPackage\pixi.toml:95:23]
94 │ platforms = ["osx-arm64"]
95 │ system-requirements = { macos = "14.0" }
· ─────────┬────────
· ╰── declare these on the `platforms` entries instead
96 │
╰────
help: e.g. platforms = [{ platform = "linux-64", cuda = "12" }]
Error launching 'python3': The system cannot find the path specified. (os error 3)
C:\Misc\ITKPythonPackage>pixi run python "C:\Misc\ITKPythonPackage\scripts\build_wheels.py" --platform-env windows-py311 --itk-source-dir C:/Dev/ITK-git
WARN Encountered 2 warnings while parsing the manifest:
⚠ the `[system-requirements]` table is deprecated in favor of virtual packages on `platforms`
╭─[C:\Misc\ITKPythonPackage\pixi.toml:82:1]
81 │
82 │ ╭─▶ [feature.manylinux228-build.system-requirements]
83 │ │ linux = "5.4"
84 │ ├─▶ libc = { family = "glibc", version = "2.28" }
· ╰──── declare these on the `platforms` entries instead
85 │
╰────
help: e.g. platforms = [{ platform = "linux-64", cuda = "12" }]
⚠ the `[system-requirements]` table is deprecated in favor of virtual packages on `platforms`
╭─[C:\Misc\ITKPythonPackage\pixi.toml:95:23]
94 │ platforms = ["osx-arm64"]
95 │ system-requirements = { macos = "14.0" }
· ─────────┬────────
· ╰── declare these on the `platforms` entries instead
96 │
╰────
help: e.g. platforms = [{ platform = "linux-64", cuda = "12" }]
Running >>>>>: git fetch --tags origin ; # in cwd=C:\Dev\ITK-git with check=False
Traceback (most recent call last):
File "C:\Misc\ITKPythonPackage\scripts\build_wheels.py", line 628, in <module>
build_wheels_main()
~~~~~~~~~~~~~~~~~^^
File "C:\Misc\ITKPythonPackage\scripts\build_wheels.py", line 450, in build_wheels_main
raise RuntimeError(
...<2 lines>...
)
RuntimeError: Failed to fetch ITK tags in C:\Dev\ITK-git: fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
C:\Misc\ITKPythonPackage>
|
This seems to be doing something: |
|
That failed too: run.log |
ef0c2d4 to
1af2b15
Compare
Windows verification complete — handing back to Linux/macOSEverything Windows-specific on this branch is now verified by real builds, and one cross-platform defect found along the way is fixed. Head is What was verified on Windows 11 / VS 2022 (i7-9800X, 32 GB)
Defects fixed on this branch by the Windows workAll Windows-only unless noted; none were reachable from Linux/macOS testing.
Plus three test fixes so the suite runs on Windows ( For Linux/macOS
|
Co-Authored-By: Cavan Riley <cavan-riley@uiowa.edu>
Co-Authored-By: Cavan Riley <cavan-riley@uiowa.edu>
Co-Authored-By: Cavan Riley <cavan-riley@uiowa.edu>
c219d94 to
afdfaf8
Compare
|
Thanks for running it locally — your Your build failure is our bug, not your invocation. The log ends at:
This PR stays WIP until the Doxygen prerequisite is resolved. "Too much Platform verification status as of afdfaf8
97 unit tests pass; One known caveat: a single aarch64 clean build failed while linking with a |
afdfaf8 to
e53db8d
Compare
|
@dzenanz thank you for the log file — it identified a real bug, and that bug is This should have been a What your log found, and the fixYour run failed at:
Two changes:
Six regression tests cover both (103 total, up from 97). Your exact command |
fb3e45b to
42922e0
Compare
1af2b15 to
ca9994a
Compare
A frozen dataclass holding the settings build_wheels.py collects in package_env_config, with precise types (Path, bool, OS, Arch, and None for settings a platform does not have). from_args_and_env() converts and validates the parsed arguments, the environment, and the resolved tools in one place, raising BuildConfigError that names the field and its value. to_environment() renders the settings as the environment variables the build tools receive, in the same keys, spellings, order, and omissions. Nothing uses it yet.
configure_one_pyproject_file and its helpers read only the ITK source directory, git tag, and package version from the whole build configuration. A frozen PyprojectInputs carries those three, so the module no longer takes a Mapping[str, Any]. The command line builds it from the env file and names every missing setting at once, where it stopped at the first with a bare KeyError. The generated pyproject.toml files are unchanged.
build_wheels.py now builds a BuildConfig and hands it to the builders, which read typed attributes in place of package_env_config lookups. The builders no longer write into the configuration: the ITKPythonPackage directories come from ipp_dir, the build type is the BUILD_TYPE constant, and the oneTBB location is the builder's tbb_dir. subprocess_environment() gives auditwheel the same variables as before, config.to_environment() followed by the builder's five keys. Input the build accepted until now and refuses at startup, naming the setting and its value: - a macOS deployment target that is not a version such as 14.0 (it produced a malformed CMAKE_OSX_DEPLOYMENT_TARGET and wheel tag); - an empty Python interpreter path from the pixi probe; - an empty ITK git tag or ITK package version. The CC and CXX lookups are removed; nothing put either key in the configuration. CMake, python -m build, and repair commands, their environments, the step table, and the build-input fingerprint settings are identical on every platform.
BuildReport and StepRecord dataclasses replace the dict[str, Any]
report in build_manager.py. to_json() writes the same keys as before
plus "version": 1; from_json() reads a report without a version field
as version 1, so build trees from earlier runs are reused as they were.
tests/data/build_log_unversioned.json is a report written by the
previous BuildManager.
A report the build used to accept and now refuses, naming the field
(the build stops with "Fix or delete it to continue", as for corrupt
JSON):
- one missing created_at, updated_at, or steps, or a step without a
status (an empty "{}" report was read as having no steps);
- a step status other than pending, running, done, or failed;
- a non-string timestamp, error, or input value, or a non-numeric
duration;
- a version other than 1;
- a malformed steps section in a report whose inputs changed, which
was ignored because every step reran.
|
Superseded by #312. Its content is byte-identical to this PR's head (same tree hash), organized as 21 commits for easier review: the Scientific Python rules first, then one commit per feature. |
Replaces the shell and PowerShell wheel-build system with a pixi-driven
Python one, and moves ITK 6 to stable-ABI (
abi3) wheels onmanylinux_2_28, macOS arm64 14.0, and Windows x86_64. Supersedes #302.
Linux and macOS wheels now build with
--dead-stripby default (port ofSimpleITK/SimpleITK#2784):
itk_coreshrinks from 89.5 to 71.4 MB on Linuxand from 61.5 to 49.3 MB on macOS, with unchanged outputs.
Successfully built on Windows, macOS arm64, Linux x86_64, and Linux
aarch64. The Doxygen/environment defect found by @dzenanz is fixed: build
tools now resolve inside the target
--platform-env, and launching fromthe wrong environment fails immediately with the environment name to use.
Build caches for all four platforms are published to ITKPythonBuilds
v6.0rc01.dev20260915; the macOS cache targets macOS 14.0. Those cachesand the platform builds below predate the eighth package,
itk-filtering-extra; the current tree has been built only on Linuxx86_64 (all 8 packages, see the
--dead-stripmeasurements).Release decisions for reviewers: a new PyPI package,
itk-filtering-extra(the filtering modules ingested from remote modules), and
itk-ionowrequires
itk-numerics.Platform verification — clean builds from this branch
Every row is a from-scratch build of this branch, not an incremental one,
made before
itk-filtering-extrawas added (hence 7 wheels).cp311-abi3-manylinux_2_28_x86_64cp311-abi3-manylinux_2_28_aarch64cp311-abi3-macosx_14_0_arm64cp311-abi3-win_amd64macOS binaries were checked with
otool -l: real.sofiles reportminos 14.0, matching theirmacosx_14_0_arm64tag. That check mattersbecause a component wheel tagged below its true
minosinstalls on oldermacOS and then fails in dyld at import — installable and broken, rather
than loudly uninstallable.
Remote-module end-to-end (the consumer path)
Proven on Windows x86_64 and Linux x86_64, each run as a fresh
consumer with zero ITK wheels present beforehand, so a leftover
artifact could not produce a false pass.
Linux x86_64, ITKBioCell, 8 minutes,
rc=0:itk_biocell-1.0.0-cp311-abi3-manylinux_2_28_x86_64.whl, 0.58 MBRequires-Dist: itk<7,>=6.0.0b1— the dependency rewrite firedauditwheelpyproject.tomlrestored byte-identical after the buildAn earlier Windows pass was found to be riding on leftover wheels; the
zero-wheel precondition was added in response and both platforms were
re-run under it.
--dead-strip: measurements
Linux links with
-ffunction-sections -fdata-sections,--gc-sections,and a version script that exports only
PyInit_*from each Python module.--no-dead-stripopts out. User-Dflags such as-DCMAKE_CXX_FLAGS:STRING=...are merged with these, not replaced.--dead-strip_ITKCommonPythonexported symbolsitk_corewheel, Linux x86_64The export limit carries the saving;
--gc-sectionsalone gave 3-5%.Linux figures are from the pushed configuration (default linker, with a
user
-DCMAKE_CXX_FLAGS:STRING=-pipemerged in). Linking with gold gavewheels about 1% smaller (
itk_core70.7 MB) and was dropped. A remotemodule (ITKSimpleITKFilters) built against the stripped wheels gives
identical output in all four old/new ITK and module combinations.
Windows needs no change: a
.pydalready exports onlyPyInit_*(84 on_ITKCommonPython), and Release links use/OPT:REF,ICFby default.macOS Python modules link with
-dead_stripand export only_PyInit_*:wheels are 20-48% smaller (
itk_core61.5 to 49.3 MB), benchmark outputsare identical, and BSpline LBFGSB registration runs 15% faster.
-dead_stripalone changed nothing (<0.1%).The 8 ITK test failures occur with and without the change and come from
the wheel configuration (unwrapped return types such as
SinusoidSpatialFunctionF4PD4,TransformToStrainFilterforTransform[D,3,3],itk.Ransac) or missing test data(
Real-DSA-01-Speed-02.mhd).Unit tests and hooks
pytest: 205 passed. pytest is a developer-only dependency; thenormal build path does not import it.
pre-commit run --all-files: exit 0, every hookPassed(black, ruff, shellcheck, shfmt, taplo, yaml/toml, whitespace).
Known caveat: intermittent aarch64 link truncation
One clean aarch64 build failed while linking:
The identical clean build then passed, with no truncation and no short
object files. Evidence points at the container file-sharing layer rather
than this branch: 158 GB free at the time, the truncated archive was
exactly 49,152 bytes (12 × 4096, a dropped write tail rather than a
partial compile), and aarch64 is the only platform writing through a
Docker bind mount onto a macOS filesystem.
Docker Desktop updated itself between the two runs (29.7.2 → 29.8.0), so
the version cannot be credited with the fix, and one pass does not
disprove an intermittent fault. Recommended handling: retry a clean
build first; do not treat a truncation as a defect in this branch.
Commit series
Topical commits, no fixups and no merge commits, now including
@dzenanz's
wheels-6.0b3series and the--dead-stripcommits. SomeBUG:commits fix earlier commits in this series; they are kept separatebecause they record distinct defects found in testing.
Beyond the build-system replacement, the series also adds:
release-wheels, one command per release build machineitk-filtering-extra, a new package for the ingested filtering modulesitk-iodepending onitk-numerics--module-itk-dir install)ITK_BUILD_JOBSoverrides)Cavan Riley is credited via
Co-Authored-Byon the seven commitscarrying his original work.