@@ -60,15 +60,33 @@ def get_exported_symbols(library, dynamic=False):
60
60
yield symbol
61
61
62
62
63
- def check_library (library , abi_funcs , dynamic = False ):
63
+ def check_library (stable_abi_file , library , abi_funcs , dynamic = False ):
64
64
available_symbols = set (get_exported_symbols (library , dynamic ))
65
65
missing_symbols = abi_funcs - available_symbols
66
66
if missing_symbols :
67
- print (
68
- f"Some symbols from the stable ABI are missing: { ', ' .join (missing_symbols )} "
67
+ raise Exception (
68
+ f"""\
69
+ Some symbols from the limited API are missing: { ', ' .join (missing_symbols )}
70
+
71
+ This error means that there are some missing symbols among the ones exported
72
+ in the Python library ("libpythonx.x.a" or "libpythonx.x.so"). This normally
73
+ means that some symbol, function implementation or a prototype, belonging to
74
+ a symbol in the limited API has been deleted or is missing.
75
+
76
+ Check if this was a mistake and if not, update the file containing the limited
77
+ API symbols. This file is located at:
78
+
79
+ { stable_abi_file }
80
+
81
+ You can read more about the limited API and its contracts at:
82
+
83
+ https://docs.python.org/3/c-api/stable.html
84
+
85
+ And in PEP 384:
86
+
87
+ https://www.python.org/dev/peps/pep-0384/
88
+ """
69
89
)
70
- return 1
71
- return 0
72
90
73
91
74
92
def generate_limited_api_symbols (args ):
@@ -107,7 +125,6 @@ def generate_limited_api_symbols(args):
107
125
)
108
126
for symbol in sorted (stable_symbols ):
109
127
output_file .write (f"{ symbol } \n " )
110
- sys .exit (0 )
111
128
112
129
113
130
def get_limited_api_macros (headers ):
@@ -187,21 +204,24 @@ def check_symbols(parser_args):
187
204
if symbol and not symbol .startswith ("#" )
188
205
}
189
206
190
- ret = 0
191
- # static library
192
- LIBRARY = sysconfig .get_config_var ("LIBRARY" )
193
- if not LIBRARY :
194
- raise Exception ("failed to get LIBRARY variable from sysconfig" )
195
- ret = check_library (LIBRARY , abi_funcs )
196
-
197
- # dynamic library
198
- LDLIBRARY = sysconfig .get_config_var ("LDLIBRARY" )
199
- if not LDLIBRARY :
200
- raise Exception ("failed to get LDLIBRARY variable from sysconfig" )
201
- if LDLIBRARY != LIBRARY :
202
- ret |= check_library (LDLIBRARY , abi_funcs , dynamic = True )
203
-
204
- sys .exit (ret )
207
+ try :
208
+ # static library
209
+ LIBRARY = sysconfig .get_config_var ("LIBRARY" )
210
+ if not LIBRARY :
211
+ raise Exception ("failed to get LIBRARY variable from sysconfig" )
212
+ check_library (parser_args .stable_abi_file , LIBRARY , abi_funcs )
213
+
214
+ # dynamic library
215
+ LDLIBRARY = sysconfig .get_config_var ("LDLIBRARY" )
216
+ if not LDLIBRARY :
217
+ raise Exception ("failed to get LDLIBRARY variable from sysconfig" )
218
+ if LDLIBRARY != LIBRARY :
219
+ check_library (
220
+ parser_args .stable_abi_file , LDLIBRARY , abi_funcs , dynamic = True
221
+ )
222
+ except Exception as e :
223
+ print (e , file = sys .stderr )
224
+ sys .exit (1 )
205
225
206
226
207
227
def main ():
0 commit comments