MCPcopy Create free account
hub / github.com/numpy/numpy / check_api_version

Function check_api_version

numpy/core/setup_common.py:84–105  ·  view source on GitHub ↗

Emits a MismatchCAPIWarning if the C API version needs updating.

(apiversion, codegen_dir)

Source from the content-addressed store, hash-verified

82 return curapi_hash, apis_hash[apiversion]
83
84def check_api_version(apiversion, codegen_dir):
85 """Emits a MismatchCAPIWarning if the C API version needs updating."""
86 curapi_hash, api_hash = get_api_versions(apiversion, codegen_dir)
87
88 # If different hash, it means that the api .txt files in
89 # codegen_dir have been updated without the API version being
90 # updated. Any modification in those .txt files should be reflected
91 # in the api and eventually abi versions.
92 # To compute the checksum of the current API, use numpy/core/cversions.py
93 if not curapi_hash == api_hash:
94 msg = ("API mismatch detected, the C API version "
95 "numbers have to be updated. Current C api version is "
96 f"{apiversion}, with checksum {curapi_hash}, but recorded "
97 f"checksum in core/codegen_dir/cversions.txt is {api_hash}. If "
98 "functions were added in the C API, you have to update "
99 f"C_API_VERSION in {__file__}."
100 "\n"
101 "Please make sure that new additions are guarded with "
102 "MinVersion() to make them unavailable when wishing support "
103 "for older NumPy versions."
104 )
105 raise MismatchCAPIError(msg)
106
107
108FUNC_CALL_ARGS = {}

Callers 1

configurationFunction · 0.70

Calls 2

get_api_versionsFunction · 0.70
MismatchCAPIErrorClass · 0.70

Tested by

no test coverage detected