2626import importlib
2727import json
2828import re
29+ import sys
2930import sysconfig
3031from pathlib import Path
3132
@@ -92,7 +93,7 @@ def check_abi(expected: dict[str, str], found: dict[str, str]) -> tuple[bool, bo
9293 return has_errors , has_allowed_changes
9394
9495
95- def check (package : str , abi_dir : Path ) -> tuple [ bool , bool ] :
96+ def check (package : str , abi_dir : Path ) -> bool :
9697 build_dir = get_package_path (package )
9798
9899 has_errors = False
@@ -126,11 +127,13 @@ def check(package: str, abi_dir: Path) -> tuple[bool, bool]:
126127
127128 if has_errors :
128129 print ("ERRORS FOUND" )
130+ return True
129131 elif has_allowed_changes :
130132 print ("Allowed changes found." )
133+ return False
131134
132135
133- def regenerate (package : str , abi_dir : Path ) -> None :
136+ def regenerate (package : str , abi_dir : Path ) -> bool :
134137 if not abi_dir .is_dir ():
135138 abi_dir .mkdir (parents = True , exist_ok = True )
136139
@@ -144,6 +147,8 @@ def regenerate(package: str, abi_dir: Path) -> None:
144147 with open (abi_path , "w" , encoding = "utf-8" ) as f :
145148 json .dump (pyx_capi_to_json (module .__pyx_capi__ ), f , indent = 2 )
146149
150+ return False
151+
147152
148153if __name__ == "__main__" :
149154 import argparse
@@ -165,4 +170,9 @@ def regenerate(package: str, abi_dir: Path) -> None:
165170 check_parser .add_argument ("dir" , help = "Input directory to read data from" )
166171
167172 args = parser .parse_args ()
168- args .func (args .package , Path (args .dir ))
173+ if hasattr (args , "func" ):
174+ if args .func (args .package , Path (args .dir )):
175+ sys .exit (1 )
176+ else :
177+ parser .print_help ()
178+ sys .exit (1 )
0 commit comments