%global pypi_name dicom2nifti Name: python-%{pypi_name} Version: 2.6.2 Release: 5%{?dist} Summary: Convert DICOM files to NIfTI format License: MIT URL: https://github.com/icometrix/dicom2nifti Source0: %{pypi_source %{pypi_name}} BuildArch: noarch BuildRequires: python3-devel # Needed for %%check's `import gdcm`, not for the build itself. Declaring it only # as a Requires meant the assertion tested a module the buildroot did not have, # and %%check failed on the very thing it was written to prove -- a check asserting # something its own environment cannot satisfy. BuildRequires: python3-gdcm %description dicom2nifti converts DICOM series to NIfTI, handling the vendor-specific variations in slice ordering, gantry tilt and multi-frame encodings that make naive conversion unreliable. It is a dependency of TotalSegmentator. %package -n python3-%{pypi_name} Summary: %{summary} # Runtime dependencies belong HERE, on the subpackage that is actually built. # Placed in the preamble through -4, so the gdcm dependency never reached the # rpm. # gdcm is handled by hand below rather than by the generator -- see %prep. Requires: python3-gdcm %description -n python3-%{pypi_name} %{summary}. %prep %autosetup -n %{pypi_name}-%{version} -p1 # Upstream depends on the PyPI distribution "python-gdcm", which ships its own # bundled GDCM build. Fedora's GDCM Python bindings come from the gdcm C++ # package as python3-gdcm and carry NO python3.Xdist(python-gdcm) provide -- # verified: `repoquery --whatprovides "python3.14dist(python-gdcm)"` returns # nothing, and neither does the bare "gdcm" spelling. So the generated # BuildRequires is unresolvable even though the module is present and importable. # # It is declared in THREE places and the first attempt at this removed none of # them. setup.py has it inline inside install_requires, not on its own line, so a # line-anchored sed did not match; and the sdist ships a PRE-GENERATED egg-info, # so requires.txt and PKG-INFO carry it independently of setup.py. There is no # pyproject.toml at all, so that half of the original sed was a no-op against a # file that does not exist. sed -i "s/,[[:space:]]*['\"]python-gdcm['\"]//" setup.py sed -i '/^python-gdcm$/d' dicom2nifti.egg-info/requires.txt sed -i '/^Requires-Dist: python-gdcm$/d' PKG-INFO dicom2nifti.egg-info/PKG-INFO # Guard across the WHOLE tree, not the two files the first version guessed at. # A guard scoped more narrowly than the thing it guards reports clean while the # problem survives -- which is exactly what happened here. if grep -rn 'python-gdcm' . ; then echo "ERROR: python-gdcm still declared somewhere above; the seds did not fully match" >&2 exit 1 fi %generate_buildrequires %pyproject_buildrequires %build %pyproject_wheel %install %pyproject_install %pyproject_save_files -l %{pypi_name} %check # Import the package AND assert the gdcm binding it actually needs is reachable, # since dropping the declaration above means the generator can no longer prove it. %pyproject_check_import %{python3} -c "import gdcm" %files -n python3-%{pypi_name} -f %{pyproject_files} # The console script. %%pyproject_save_files covers the importable module tree but # not entry-point wrappers, so /usr/bin/dicom2nifti has to be listed explicitly or # rpm fails the build as an unpackaged file -- which is the correct behaviour and # is how this was found. %{_bindir}/%{pypi_name} %changelog * Sat Sep 26 2026 Morgan Hough - 2.6.2-4 - Package the /usr/bin/dicom2nifti console script. %%pyproject_save_files lists the importable module tree but not entry-point wrappers, so rpm correctly failed the build on an unpackaged file. - Fourth iteration, every failure caught in local mock rather than COPR, and each one moved forward: -1 the seds matched none of the three python-gdcm declarations, -2 %%check asserted a module absent from the buildroot, -3 the check passed and the file list was short, -4 this. * Fri Sep 25 2026 Morgan Hough - 2.6.2-3 - Add BuildRequires: python3-gdcm. The -2 %%check asserted `import gdcm` while gdcm was declared only as a Requires, so it was absent from the buildroot and the check failed on the exact thing it existed to verify. The %%prep seds and the tree-wide guard worked correctly in -2; only the check environment was wrong. * Fri Sep 25 2026 Morgan Hough - 2.6.2-1 - Initial package. Required by TotalSegmentator, which the shipped 3dslicer-totalsegmentator extension imports but nothing provides. - Upstream's "python-gdcm" dependency is dropped in %%prep and replaced with an explicit Requires on Fedora's python3-gdcm: the PyPI distribution bundles its own GDCM, and Fedora's bindings carry no python3.Xdist(python-gdcm) provide, so the generated BuildRequires would be unresolvable. %%check asserts `import gdcm` works, because removing the declaration removes the generator's proof.