Skip to content

Commit cdbb486

Browse files
hjmjohnsonclaude
andcommitted
ENH: Restrict Strategy 1 dep rewrite to ITK base sub-packages only
Limit the build-time pyproject.toml rewrite to the six ITK base sub-packages (itk-core, itk-numerics, itk-io, itk-filtering, itk-registration, itk-segmentation) whose versions are tied to the ITK release. Remote module cross-deps like itk-meshtopolydata are versioned independently and are not rewritten — a warning is printed instead so they can be reviewed manually. Prevents incorrect rewriting of e.g. itk-meshtopolydata == 0.12.* in BSplineGradient and WebAssemblyInterface. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b7a1dd0 commit cdbb486

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

scripts/build_python_instance_base.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,36 @@ def _update_module_itk_deps(pyproject_path: Path, itk_version: str) -> bool:
805805

806806
# --- Strategy 1: build-time rewrite (fallback) ------------------------
807807
text = pyproject_path.read_text(encoding="utf-8")
808-
# Match lines like: "itk-core == 5.4.*" or "itk-filtering==5.4.*"
808+
809+
# Only rewrite ITK *base* sub-packages whose versions are tied to
810+
# the ITK release. Remote module cross-deps (e.g.
811+
# itk-meshtopolydata == 0.12.*) are versioned independently and
812+
# must NOT be rewritten — flag them for manual review instead.
813+
_ITK_BASE_PACKAGES = (
814+
"itk-core",
815+
"itk-numerics",
816+
"itk-io",
817+
"itk-filtering",
818+
"itk-registration",
819+
"itk-segmentation",
820+
)
821+
_base_pkg_alt = "|".join(re.escape(p) for p in _ITK_BASE_PACKAGES)
809822
pattern = re.compile(
810-
r'"(itk-[a-z]+)\s*==\s*[\d]+\.[\d]+\.\*"'
823+
rf'"({_base_pkg_alt})\s*==\s*[\d]+\.[\d]+\.\*"'
824+
)
825+
826+
# Warn about pinned remote-module cross-deps that may also need
827+
# attention but should not be auto-rewritten.
828+
cross_dep_pattern = re.compile(
829+
r'"(itk-[a-z][a-z0-9-]*)\s*==\s*[\d]+\.[\d]+\.\*"'
811830
)
831+
for m in cross_dep_pattern.finditer(text):
832+
pkg = m.group(1)
833+
if pkg not in _ITK_BASE_PACKAGES:
834+
print(
835+
f" WARNING: {pyproject_path.name} pins remote module "
836+
f"cross-dep {m.group(0)} — review manually"
837+
)
812838

813839
# Determine the minimum version floor from the ITK version being built.
814840
# For "6.0.0b2.post757" -> major "6", floor "5.4" (backward compat).

0 commit comments

Comments
 (0)