From 073916e667f6b466422071a19b7e67d7adb8ea5e Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 3 Sep 2026 09:43:12 -0700 Subject: [PATCH] toolshed/check_spdx.py: ensure all LICENSE files across the entire repo are identical This avoids: * hard-coded LICENSE filepaths. * checking the same LICENSE files multiple times, depending on how pre-commit batches the files. --- cuda_pathfinder/LICENSE | 2 +- toolshed/check_spdx.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cuda_pathfinder/LICENSE b/cuda_pathfinder/LICENSE index 3b3fdce8194..f3fe76ecadf 100644 --- a/cuda_pathfinder/LICENSE +++ b/cuda_pathfinder/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. Apache License Version 2.0, January 2004 diff --git a/toolshed/check_spdx.py b/toolshed/check_spdx.py index d4c9430673c..33276250e00 100644 --- a/toolshed/check_spdx.py +++ b/toolshed/check_spdx.py @@ -36,6 +36,19 @@ } SPDX_IGNORE_FILENAME = ".spdx-ignore" +REPOSITORY_LICENSE_CONTENTS = Path("LICENSE").read_bytes() + + +def license_files_match_repository(filepaths): + licenses_match = True + for filepath in filepaths: + license_path = Path(filepath) + if license_path.name != "LICENSE": + continue + if license_path.read_bytes() != REPOSITORY_LICENSE_CONTENTS: + print(f"PACKAGE LICENSE {filepath!r} does not match repository LICENSE") + licenses_match = False + return licenses_match def load_spdx_ignore(): @@ -203,9 +216,12 @@ def main(args): else: fix = False + returncode = 0 + if not license_files_match_repository(args): + returncode = 1 + ignore_spec = load_spdx_ignore() - returncode = 0 for filepath in args: if ignore_spec.match_file(filepath): continue