File tree Expand file tree Collapse file tree 4 files changed +67
-14
lines changed
Expand file tree Collapse file tree 4 files changed +67
-14
lines changed Original file line number Diff line number Diff line change 4747 run : python scripts/cpplint.py
4848
4949 - name : Check license headers (REUSE)
50- run : scripts/check_license.sh
50+ run : python scripts/check_license.py
5151
5252 - name : Check inline samples are up to date
5353 run : python test/tools/inline_samples.py --check
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: Copyright (c) <2026> NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+ #
3+ # SPDX-License-Identifier: Apache-2.0
4+
5+ import subprocess
6+ import sys
7+
8+ skip_patterns = [
9+ "VERSION" ,
10+ ".svg" ,
11+ "uv.lock" ,
12+ "LICENSES/" ,
13+ ]
14+
15+ max_lines_to_check = 10
16+
17+
18+ def check_license ():
19+ result = subprocess .run (
20+ ["git" , "ls-files" ],
21+ capture_output = True ,
22+ text = True ,
23+ check = True ,
24+ )
25+ bad_files = 0
26+ num_files = 0
27+
28+ for filepath in result .stdout .splitlines ():
29+ if any (s in filepath for s in skip_patterns ):
30+ continue
31+ try :
32+ with open (filepath , "r" ) as f :
33+ head = ""
34+ for i , line in enumerate (f ):
35+ if i >= max_lines_to_check :
36+ break
37+ head += line
38+ except (UnicodeDecodeError , OSError ):
39+ continue
40+
41+ if not head :
42+ continue
43+ num_files += 1
44+ has_error = False
45+ if "SPDX-FileCopyrightText" not in head :
46+ print (f"{ filepath } : no copyright notice" , file = sys .stderr )
47+ has_error = True
48+ if "SPDX-License-Identifier" not in head :
49+ print (f"{ filepath } : no license identifier" , file = sys .stderr )
50+ has_error = True
51+ if has_error :
52+ bad_files += 1
53+
54+ if bad_files > 0 :
55+ print (f"Found { bad_files } files with missing or incomplete license headers" ,
56+ file = sys .stderr )
57+ sys .exit (1 )
58+ elif num_files == 0 :
59+ print ("No input files found!" , file = sys .stderr )
60+ sys .exit (2 )
61+ else :
62+ print (f"Checked { num_files } files, all OK" )
63+
64+
65+ if __name__ == "__main__" :
66+ check_license ()
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ pytest-cov==6.2.1
99pytest-env == 1.2.0
1010flake8 == 7.3.0
1111pytest-cov == 6.2.1
12- reuse == 5.1.0
1312
1413numba-cuda [cu13 ]== 0.20.0
1514cupy-cuda13x == 13.6.0
You can’t perform that action at this time.
0 commit comments