Skip to content

Commit 3292325

Browse files
hjmjohnsonclaude
andcommitted
DOC: Add Strategy 3 migration plan to _update_module_itk_deps
Document the plan to migrate from build-time pyproject.toml rewriting (Strategy 1) to a scikit-build-core dynamic metadata provider (Strategy 3) that resolves ITK dependency versions at build time without modifying source files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7b8c475 commit 3292325

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

scripts/build_python_instance_base.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,49 @@ def _update_module_itk_deps(pyproject_path: Path, itk_version: str) -> bool:
720720
wheels produced for ITK 6 can be installed alongside ITK 6
721721
packages without pip dependency conflicts.
722722
723+
.. note:: Strategy 1 (build-time rewrite) — interim solution.
724+
725+
This approach rewrites the module's pyproject.toml on disk,
726+
builds the wheel, then restores the original. It works today
727+
with zero changes to remote modules but is inherently fragile
728+
(regex-based, modifies the source tree).
729+
730+
**Plan to migrate to Strategy 3 (scikit-build-core dynamic
731+
metadata provider):**
732+
733+
1. Create a small installable package ``itk-build-metadata``
734+
that implements the scikit-build-core dynamic metadata
735+
provider interface (see scikit-build-core docs:
736+
``tool.scikit-build.metadata.<field>.provider``).
737+
738+
2. The provider inspects the build environment at wheel-build
739+
time to discover the ITK version — either from the
740+
``ITK_PACKAGE_VERSION`` env var (set by this build system),
741+
from ``ITKConfig.cmake`` on ``CMAKE_PREFIX_PATH``, or from
742+
an already-installed ``itk-core`` package.
743+
744+
3. It emits the correct ``Requires-Dist`` entries (e.g.
745+
``itk-io >= 5.4``) into the wheel metadata without
746+
touching ``pyproject.toml`` on disk at all.
747+
748+
4. Remote modules opt in by declaring dynamic dependencies::
749+
750+
[project]
751+
dynamic = ["dependencies"]
752+
753+
[tool.scikit-build.metadata.dependencies]
754+
provider = "itk_build_metadata"
755+
provider-path = "." # or from installed package
756+
757+
5. Roll out incrementally: update ITKModuleTemplate first,
758+
then migrate existing modules via the ``/update-itk-deps``
759+
skill (in REMOTE_MODULES/.claude/skills/). Modules that
760+
have not migrated continue to work via this Strategy 1
761+
fallback, so both approaches coexist during the transition.
762+
763+
6. Once all ~60 remote modules have adopted Strategy 3,
764+
this method can be removed.
765+
723766
Parameters
724767
----------
725768
pyproject_path : Path

0 commit comments

Comments
 (0)