STYLE: Add SPDX license identifiers to all ITK source files#6063
Merged
hjmjohnson merged 0 commit intoInsightSoftwareConsortium:copilot/generate-sbom-at-build-timefrom Apr 18, 2026
Conversation
21b931c to
1d05a10
Compare
1d05a10 to
42b4ef7
Compare
Contributor
|
Too many files changed for review. ( |
929f4ff to
99398c8
Compare
b765be7 to
2dee212
Compare
4229b7d to
8a49700
Compare
hjmjohnson
added a commit
to hjmjohnson/ITK
that referenced
this pull request
Apr 18, 2026
Adds Utilities/Maintenance/AddSPDXHeaders.py: a Python 3.10+ script
that prepends the two SPDX lines
// SPDX-FileCopyrightText: Copyright NumFOCUS
// SPDX-License-Identifier: Apache-2.0
to ITK-owned source files following VTK's convention. Python, CMake,
and shell files use the equivalent `#`-prefix syntax.
This is the tool that produced the 5,698-file diff in the companion
PR InsightSoftwareConsortium#6063. The script is idempotent, skips files that already carry
an SPDX header, and handles the following edge cases:
* shebang preservation (Python scripts)
* UTF-8 BOM preservation (BOM stays at byte 0)
* CRLF line-ending detection and preservation
* needs_spdx() scans only the first 50 lines so scripts that
legitimately mention SPDX-License-Identifier in their docstrings
(including this script itself) are correctly identified
Usage modes:
# Walk the whole ITK source tree:
python3 AddSPDXHeaders.py [--dry-run] [ITK_SOURCE_DIR]
# Operate on a specific file list (for pre-commit integration):
python3 AddSPDXHeaders.py --files <file1> <file2> ...
# Check-only mode: exit non-zero if any file needs SPDX:
python3 AddSPDXHeaders.py --check --files <file1> <file2> ...
Hooking the script into pre-commit comes in a subsequent commit.
The matching KWStyle template update landed with the per-file SPDX
tagging in PR InsightSoftwareConsortium#6063.
8a49700
into
InsightSoftwareConsortium:copilot/generate-sbom-at-build-time
1 of 9 checks passed
2dee212 to
61332b1
Compare
This was referenced Apr 18, 2026
Member
Author
|
This PR was auto-closed as "merged" by GitHub when a force-push to Replaced by #6084 — same content (bulk SPDX tagging on 5,698 files + KWStyle template update), now correctly targeting All review discussion should move to #6084. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add machine-readable SPDX headers to all 5,503 ITK-owned source files following VTK's convention. This completes Phase 2 of the SBOM roadmap (#4302), complementing the SBOM generation in #5817.
Format (matching VTK)
C/C++ files:
Python files:
Scope
.h,.hxx,.cxx,.txx,.py,.cmake,CMakeLists.txt)Utilities/KWStyle/ITKHeader.htemplate updated to enforce SPDX on new filesUtilities/Maintenance/AddSPDXHeaders.pyfor reuseWhy both SPDX lines and existing header?
The existing 17-line Apache-2.0 block is the human-readable legal notice. The SPDX lines are the machine-readable equivalent, parseable by REUSE,
scancode-toolkit,fossology, and other license compliance tools. Both forms are standard practice — VTK, CMake, KDE, and FSFE projects use this dual approach.