%global pypi_name icon_registration Name: python-icon-registration Version: 1.1.8 Release: 1%{?dist} Summary: Deep-learning image registration with inverse-consistency regularisation # GitHub reports "NOASSERTION" for this repo. The LICENSE file is the short-form # Apache-2.0 grant ("Licensed under the Apache License, Version 2.0"), and the # PyPI classifier agrees. Read from the file, not from the index. License: Apache-2.0 URL: https://github.com/uncbiag/ICON Source0: %{pypi_source %{pypi_name}} BuildArch: noarch BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros # Needed for %%check. Stripping itk from install_requires (see %%prep) removes the # GENERATED dependency, which also removes it from the buildroot -- so eleven # modules failed with "No module named 'itk'" until this was added. The runtime # Requires below is the other half of the same fix. BuildRequires: python3-itk %global _description %{expand: ICON trains registration networks with a regulariser that penalises departure from inverse consistency, so the forward and reverse transforms agree without being constrained to be exact inverses. It provides the network wrappers, losses and training loop used by GradICON and uniGradICON. The import name is "icon_registration".} %description %{_description} %package -n python3-icon-registration Summary: %{summary} # ITK is required and CANNOT be generated. python3-itk 5.4.7 exists in this # COPR but provides only python-itk / python3-itk / python3.15-itk -- it emits # NO python3dist(itk) at all, so upstream's "itk>=5.3a" would become an # unsatisfiable generated dependency. Stripped in %%prep and stated here by hand. Requires: python3-itk # Training only, and deliberately NOT required: # tensorboard -- not packaged for Fedora at all (checked under # python3dist(tensorboard), tensorboardx, # tensorboard-data-server, and an rpm-name glob, against a # config whose control query returned python3-numpy). It is # imported INSIDE functions in train.py and # unicarl/unigradicon_train_parallel.py, never at module # scope, and it goes through torch.utils.tensorboard which # python3-torch already ships. Inference does not touch it. # Packaging tensorboard is a project of its own -- it pulls absl-py, grpcio, # markdown, protobuf and a Rust binary (tensorboard-data-server). Rather than # block this package behind that, the dependency is removed and the limitation # is recorded: TRAINING with tensorboard logging will not work until it exists. Recommends: python3-footsteps %description -n python3-icon-registration %{_description} %prep %autosetup -n %{pypi_name}-%{version} # Remove two entries from install_requires that cannot be satisfied as written. # Both are checked afterwards so this fails loudly if upstream reformats # setup.cfg, rather than silently leaving a dependency behind. # # tensorboard -- absent from Fedora; lazily imported, training-only (above) # itk>=5.3a -- python3-itk provides no python3dist(itk); real Requires above # NOTE grep -P throughout. sed understands \t in a regex; grep's default BRE # does NOT -- it warns "stray \ before t" and never matches, so a guard written # with plain grep reports failure whatever the file says. That is how the first # build of this package died: the sed worked and the guard lied. sed -i -e '/^\ttensorboard$/d' -e '/^\titk>=5.3a$/d' setup.cfg grep -qP '^\ttensorboard$' setup.cfg && { echo "ERROR: tensorboard still in install_requires" >&2; exit 1; } grep -qP '^\titk>=5\.3a$' setup.cfg && { echo "ERROR: itk still in install_requires" >&2; exit 1; } # And confirm the ones we DO want are still there, so the sed cannot quietly # have eaten the whole block. grep -qP '^\tfootsteps>=0\.1\.6$' setup.cfg || { echo "ERROR: install_requires looks wrong after sed" >&2; exit 1; } %generate_buildrequires %pyproject_buildrequires %build %pyproject_wheel %install %pyproject_install %pyproject_save_files icon_registration %check # Import only. The test suite downloads training data from a Girder server. # # Two modules are excluded, both because they import packages Fedora does not # have, identified from a failing check rather than guessed: # icon_registration.data -> elasticdeform, undeclared upstream and # not packaged; a retina-dataset loader # icon_registration.train -> tensorboard, stripped above # Four more are excluded for a reason that is NOT this package's fault: # constricon, unicarl.fixed_point_carl, unicarl.register, # unicarl.unigradicon_train_parallel -> all `import torchvision`, which is # BROKEN IN FEDORA on f45 and rawhide. torchvision 0.27.1 against torch # 2.12.0 raises AttributeError: '_OpNamespace' 'torchvision' object has no # attribute '_cuda_version' at import. Already written up in # docs/upstream/fedora-torchvision-cuda-version.md; f44 is unaffected. These # four will import as soon as Fedora fixes torchvision, with no change here. # # Keep this list honest: every exclusion above names a package that is absent # or broken, not a module of ours that fails. All ONE-LINE, because rpm parses # a macro's arguments from a single physical line and backslash continuations # are eaten by the shell AFTER expansion -- the flags vanish silently. %pyproject_check_import -e icon_registration.data -e icon_registration.train -e icon_registration.constricon -e icon_registration.unicarl.fixed_point_carl -e icon_registration.unicarl.register -e icon_registration.unicarl.unigradicon_train_parallel %files -n python3-icon-registration -f %{pyproject_files} %license LICENSE %doc README.md %changelog * Tue Sep 29 2026 Morgan Hough - 1.1.8-1 - Initial package: icon-registration 1.1.8, from the UNC BIAG group. A dependency of unigradicon, and both are in the dependency set of Project-MONAI/monai-physio. - Pure Python, noarch, nothing compiled and nothing bundled. python_requires is ">=3.4" with no upper bound, so f45's Python 3.15 is in range. - TWO DEPENDENCIES STRIPPED IN %%prep, for different reasons, each with a guard that fails the build if upstream reformats setup.cfg: * itk>=5.3a -- we HAVE python3-itk 5.4.7, but it provides no python3dist(itk); its only provides are python-itk, python3-itk, python3-itk(x86-64) and python3.15-itk. The generated dependency would be unsatisfiable against a package that is installed and working, so it is replaced by an explicit Requires: python3-itk. This is a gap in the ITK spec, not in this one, and it will bite every Python package that declares a dependency on itk. * tensorboard -- not in Fedora under any name I could find, and packaging it means absl-py, grpcio, markdown, protobuf and a Rust binary (tensorboard-data-server). It is imported INSIDE functions, training-only, via torch.utils.tensorboard which python3-torch already ships. Inference works without it; training with tensorboard logging does not. Recorded as a known limitation rather than a hidden one. - Four modules (constricon, unicarl.fixed_point_carl, unicarl.register, unicarl.unigradicon_train_parallel) are excluded because they import torchvision, which is BROKEN in Fedora on f45/rawhide -- AttributeError on torch.ops.torchvision._cuda_version at import, already documented in docs/upstream/fedora-torchvision-cuda-version.md. Not our defect and not fixable here; they will import once Fedora fixes torchvision. - BuildRequires: python3-itk is needed as well as the runtime Requires. Stripping itk from install_requires removes the generated dependency, and with it the buildroot entry, so %%check failed on eleven modules with "No module named 'itk'" until it was declared explicitly. - The %%prep guards use grep -P deliberately. sed interprets \t in a regex and grep's default BRE does not: it warns "stray \ before t" and never matches, so a plain-grep guard fails regardless of the file's contents. The first build died exactly that way -- the sed had worked and the guard was wrong. - icon_registration.data and .train are excluded from the import check: data needs elasticdeform (undeclared upstream, unpackaged) and train needs the stripped tensorboard. Everything else imports.