diff --git a/.builders/scripts/repair_wheels.py b/.builders/scripts/repair_wheels.py index 2168053b3afdf..bae851cc2d895 100644 --- a/.builders/scripts/repair_wheels.py +++ b/.builders/scripts/repair_wheels.py @@ -16,6 +16,9 @@ import urllib3 from utils import extract_metadata, normalize_project_name +# Packages for which we're skipping the openssl-3 build check +OPENSSL_PACKAGE_BYPASS = ["psycopg"] + @cache def get_wheel_hashes(project) -> dict[str, str]: @@ -97,6 +100,28 @@ def __str__(self): ]) + '.whl' +def check_unacceptable_files( + wheel: Path, + bypass_prefixes: list[str], + invalid_file_patterns: list[str], +): + """Check if a wheel contains any unacceptable files and exit if found.""" + if any(wheel.name.startswith(pkg_prefix) for pkg_prefix in bypass_prefixes): + print( + f'Warning: Bypassing unacceptable file check for {wheel.name}' + ) + return + + unacceptable_files = find_patterns_in_wheel(wheel, invalid_file_patterns) + if unacceptable_files: + print( + f"Found copies of unacceptable files in external wheel '{wheel.name}'", + f'(matching {invalid_file_patterns}): ', + unacceptable_files, + ) + sys.exit(1) + + def repair_linux(source_dir: str, built_dir: str, external_dir: str) -> None: from auditwheel.patcher import Patchelf from auditwheel.policy import WheelPolicies @@ -129,15 +154,11 @@ def repair_linux(source_dir: str, built_dir: str, external_dir: str) -> None: if not wheel_was_built(wheel): print('Using existing wheel') - unacceptable_files = find_patterns_in_wheel(wheel, external_invalid_file_patterns) - if unacceptable_files: - print( - f"Found copies of unacceptable files in external wheel '{wheel.name}'", - f'(matching {external_invalid_file_patterns}): ', - unacceptable_files, - ) - sys.exit(1) - + check_unacceptable_files( + wheel, + bypass_prefixes=OPENSSL_PACKAGE_BYPASS, + invalid_file_patterns=external_invalid_file_patterns, + ) shutil.move(wheel, external_dir) continue @@ -179,15 +200,11 @@ def repair_windows(source_dir: str, built_dir: str, external_dir: str) -> None: if not wheel_was_built(wheel): print('Using existing wheel') - unacceptable_files = find_patterns_in_wheel(wheel, external_invalid_file_patterns) - if unacceptable_files: - print( - f"Found copies of unacceptable files in external wheel '{wheel.name}'", - f'(matching {external_invalid_file_patterns}): ', - unacceptable_files, - ) - sys.exit(1) - + check_unacceptable_files( + wheel, + bypass_prefixes=OPENSSL_PACKAGE_BYPASS, + invalid_file_patterns=external_invalid_file_patterns, + ) shutil.move(wheel, external_dir) continue