Skip to content

Commit e4b0ea2

Browse files
Make license compliance failures a RuntimeError
1 parent df6ad28 commit e4b0ea2

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

make_wheels.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
'powerpc64le-linux': 'manylinux_2_17_ppc64le.manylinux2014_ppc64le.musllinux_1_1_ppc64le',
3131
}
3232

33+
_YELLOW = "\033[93m"
34+
3335

3436
class ReproducibleWheelFile(WheelFile):
3537
def writestr(self, zinfo_or_arcname, data, *args, **kwargs):
@@ -142,6 +144,10 @@ def write_ziglang_wheel(out_dir, *, version, platform, archive):
142144
]
143145
license_regex = re.compile('|'.join(f'^{pattern}$' for pattern in license_patterns), re.IGNORECASE)
144146

147+
# These file paths MUST remain in sync with the paths in the official
148+
# Zig tarballs and with the ones defined below in the metadata. The
149+
# script will raise an error if any of these files are not found in
150+
# the archive.
145151
required_license_paths = [
146152
'LICENSE',
147153
'lib/libc/glibc/LICENSES',
@@ -191,14 +197,20 @@ def write_ziglang_wheel(out_dir, *, version, platform, archive):
191197
# 1. Check for missing required licenses paths
192198
missing_licenses = set(required_license_paths) - found_license_files
193199
if missing_licenses:
194-
print(f"\033[93mWarning: the following required license files were not found in the Zig archive: {', '.join(sorted(missing_licenses))} "
195-
"\nThis may indicate a change in Zig's license file structure or an error in the listing of license files and/or paths.\033[0m")
200+
error_message = (
201+
f"{_YELLOW}The following required license files were not found in the Zig archive: {', '.join(sorted(missing_licenses))} "
202+
f"\nThis may indicate a change in Zig's license file structure or an error in the listing of license files and/or paths.{_YELLOW}"
203+
)
204+
raise RuntimeError(error_message)
196205

197206
# 2. Check for potentially missing license files
198207
extra_licenses = potential_extra_licenses - set(required_license_paths)
199208
if extra_licenses:
200-
print(f"\033[93mWarning: found additional potential license files in the Zig archive but not included in the metadata: {', '.join(sorted(extra_licenses))} "
201-
"\nPlease consider adding these to the license paths if they should be included.\033[0m")
209+
error_message = (
210+
f"{_YELLOW}Found additional potential license files in the Zig archive but not included in the metadata: {', '.join(sorted(extra_licenses))} "
211+
f"\nPlease consider adding these to the license paths if they should be included.{_YELLOW}"
212+
)
213+
raise RuntimeError(error_message)
202214

203215
with open('README.pypi.md') as f:
204216
description = f.read()

0 commit comments

Comments
 (0)