Skip to content

Commit eef3902

Browse files
committed
toolshed: normalize SPDX paths with PureWindowsPath
Use a standard-library path normalizer so repo-prefix checks treat Windows-style paths consistently on any host. Document why os.path.normpath is not suitable for this forward-slash prefix comparison. Made-with: Cursor
1 parent 36a4914 commit eef3902

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

toolshed/check_spdx.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import re
77
import subprocess
88
import sys
9+
from pathlib import PureWindowsPath
910

1011
import pathspec
1112

@@ -50,10 +51,11 @@ def is_staged(filepath):
5051

5152

5253
def normalize_repo_path(filepath):
53-
normalized_path = filepath.replace("\\", "/")
54-
while normalized_path.startswith("./"):
55-
normalized_path = normalized_path[2:]
56-
return normalized_path
54+
# We compare against repo prefixes like "cuda_core/" regardless of host OS.
55+
# os.path.normpath is host-dependent: on POSIX it leaves "\" untouched, and
56+
# on Windows it normalizes to "\" separators, so neither gives a stable
57+
# forward-slash form for this prefix check.
58+
return PureWindowsPath(filepath).as_posix()
5759

5860

5961
def get_expected_license_identifier(filepath):

0 commit comments

Comments
 (0)