summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-05-26 16:05:05 -0700
committerGitHub <noreply@github.com>2022-05-26 16:05:05 -0700
commit5085513b8bb72da7635eaa4a8f581a4b6fb1502d (patch)
tree8eae3074f8c9c0927dd1666e9c2b651feead700e
parent6014a39cb4d979a334b20b05342f82766a7840cf (diff)
parent54a7b0b9843e2e89b217eaa38550752bb4754119 (diff)
downloadnumpy-5085513b8bb72da7635eaa4a8f581a4b6fb1502d.tar.gz
Merge pull request #21611 from mattip/check_api_version
MAINT: make MismatchCAPIWarnining into MismatchCAPIError
-rw-r--r--numpy/core/setup.py5
-rw-r--r--numpy/core/setup_common.py15
2 files changed, 8 insertions, 12 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index fe9020111..41f702bd1 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -476,11 +476,8 @@ def configuration(parent_package='',top_path=None):
local_dir = config.local_path
codegen_dir = join(local_dir, 'code_generators')
- if is_released:
- warnings.simplefilter('error', MismatchCAPIWarning)
-
# Check whether we have a mismatch between the set C API VERSION and the
- # actual C API VERSION
+ # actual C API VERSION. Will raise a MismatchCAPIError if so.
check_api_version(C_API_VERSION, codegen_dir)
generate_umath_py = join(codegen_dir, 'generate_umath.py')
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
index 81a86728a..27281fd34 100644
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -51,7 +51,7 @@ C_ABI_VERSION = 0x01000009
# 0x00000010 - 1.24.x
C_API_VERSION = 0x00000010
-class MismatchCAPIWarning(Warning):
+class MismatchCAPIError(ValueError):
pass
@@ -87,14 +87,13 @@ def check_api_version(apiversion, codegen_dir):
# To compute the checksum of the current API, use numpy/core/cversions.py
if not curapi_hash == api_hash:
msg = ("API mismatch detected, the C API version "
- "numbers have to be updated. Current C api version is %d, "
- "with checksum %s, but recorded checksum for C API version %d "
- "in core/codegen_dir/cversions.txt is %s. If functions were "
- "added in the C API, you have to update C_API_VERSION in %s."
+ "numbers have to be updated. Current C api version is "
+ f"{apiversion}, with checksum {curapi_hash}, but recorded "
+ f"checksum in core/codegen_dir/cversions.txt is {api_hash}. If "
+ "functions were added in the C API, you have to update "
+ f"C_API_VERSION in {__file__}."
)
- warnings.warn(msg % (apiversion, curapi_hash, apiversion, api_hash,
- __file__),
- MismatchCAPIWarning, stacklevel=2)
+ raise MismatchCAPIError(msg)
FUNC_CALL_ARGS = {}