Skip to content

Commit

Permalink
MAINT: rename LIBPY_MAIN to LIBPY_TEST_MAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Jevnik authored and llllllllll committed Apr 16, 2019
1 parent 1e8690e commit bfadd79
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions include/libpy/numpy_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
// (`LIBPY_COMPILING_FOR_TESTS`) which will control the `NO_IMPORT_ARRAY` flag. This flag
// tells numpy to declare the `PyArray_API` flag as an `extern "C" void** PyArray_API`,
// meaning we expect to have this symbol defined by another object we are to be linked
// with. In `main.cc` we also set `LIBPY_MAIN` to disable this feature, but instead define
// `PY_ARRAY_UNIQUE_SYMBOL` which causes changes the declaration of `PyArray_API` to
// change to: `#define PyArray_API PY_ARRAY_UNIQUE_SYMBOL` and then `void**
// with. In `main.cc` we also set `LIBPY_TEST_MAIN` to disable this feature, but instead
// define `PY_ARRAY_UNIQUE_SYMBOL` which causes changes the declaration of `PyArray_API`
// to change to: `#define PyArray_API PY_ARRAY_UNIQUE_SYMBOL` and then `void**
// PyArray_API`. Importantly, this removes the `static` causing the symbol to have
// external linkage. Then, because the tests are declaring the same symbol as extern, they
// will all resolve to the same `PyArray_API` instance and we only need to call
// `import_array` once in `main.cc`.
#if defined(LIBPY_COMPILING_FOR_TESTS) && !defined(LIBPY_MAIN)
#if defined(LIBPY_COMPILING_FOR_TESTS) && !defined(LIBPY_TEST_MAIN)
#define NO_IMPORT_ARRAY
#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_libpy
#endif
Expand Down
2 changes: 1 addition & 1 deletion testleaks.supp
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ leak:_ctypes.cpython
leak:_ctypes.x86_64-linux-gnu.so
leak:numpy/core/src/multiarray/arraytypes.c.src
leak:numpy/core/src/multiarray/alloc.c
leak:numpy/core/src/multiarray/ctors.c
leak:numpy/core/src/multiarray/ctors.c
2 changes: 1 addition & 1 deletion tests/main.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gtest/gtest.h"
#include <Python.h>

#define LIBPY_MAIN
#define LIBPY_TEST_MAIN
#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_libpy
#include "libpy/numpy_utils.h"

Expand Down

0 comments on commit bfadd79

Please sign in to comment.