diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2017-04-26 13:13:54 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2017-04-26 14:31:29 -0600 |
commit | 39a21ddf4deb32a6a7db5a0b890f064166c04a77 (patch) | |
tree | 5e6faf2fe634896c6bffd6f17eb715d69e5a79c6 /numpy/core/setup.py | |
parent | 4408f743db8b5a15e9d0b5ace39ef12cafa1bce3 (diff) | |
download | numpy-39a21ddf4deb32a6a7db5a0b890f064166c04a77.tar.gz |
TST: Enable NPY_RELAXED_STRIDES_DEBUG environment variable.
Setting NPY_RELAXED_STRIDES_DEBUG=1 in the enviroment when relaxed
stride checking is enabled will cause numpy to be compiled with affected
strides set to bogus values in order to help smoke out incorrect usage
of strides in downstream projects.
Diffstat (limited to 'numpy/core/setup.py')
-rw-r--r-- | numpy/core/setup.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py index a22d1ef9d..20d4c7792 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -20,6 +20,12 @@ from setup_common import * # that `strides[dim]` is ignored if `shape[dim] == 1` when setting flags. NPY_RELAXED_STRIDES_CHECKING = (os.environ.get('NPY_RELAXED_STRIDES_CHECKING', "1") != "0") +# Put NPY_RELAXED_STRIDES_DEBUG=1 in the environment if you want numpy to use a +# bogus value for affected strides in order to help smoke out bad stride usage +# when relaxed stride checking is enabled. +NPY_RELAXED_STRIDES_DEBUG = (os.environ.get('NPY_RELAXED_STRIDES_DEBUG', "0") != "0") +NPY_RELAXED_STRIDES_DEBUG = NPY_RELAXED_STRIDES_DEBUG and NPY_RELAXED_STRIDES_CHECKING + # XXX: ugly, we use a class to avoid calling twice some expensive functions in # config.h/numpyconfig.h. I don't see a better way because distutils force # config.h generation inside an Extension class, and as such sharing @@ -436,9 +442,14 @@ def configuration(parent_package='',top_path=None): # Inline check inline = config_cmd.check_inline() + # Use relaxed stride checking if NPY_RELAXED_STRIDES_CHECKING: moredefs.append(('NPY_RELAXED_STRIDES_CHECKING', 1)) + # Use bogus stride debug aid when relaxed strides are enabled + if NPY_RELAXED_STRIDES_DEBUG: + moredefs.append(('NPY_RELAXED_STRIDES_DEBUG', 1)) + # Get long double representation if sys.platform != 'darwin': rep = check_long_double_representation(config_cmd) @@ -542,6 +553,9 @@ def configuration(parent_package='',top_path=None): if NPY_RELAXED_STRIDES_CHECKING: moredefs.append(('NPY_RELAXED_STRIDES_CHECKING', 1)) + if NPY_RELAXED_STRIDES_DEBUG: + moredefs.append(('NPY_RELAXED_STRIDES_DEBUG', 1)) + # Check wether we can use inttypes (C99) formats if config_cmd.check_decl('PRIdPTR', headers=['inttypes.h']): moredefs.append(('NPY_USE_C99_FORMATS', 1)) |