Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Fix compilation error since python 3.11 and macOS #8

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bfloat16.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ limitations under the License.

#include <Python.h>
#include <cinttypes>
#include <patchlevel.h>
#include <vector>
#ifdef DEBUG_CALLS
#include <iostream>
Expand Down Expand Up @@ -1745,7 +1746,13 @@ namespace greenwaves
NPyBfloat16_ArrFuncs.argmax = NPyBfloat16_ArgMaxFunc;
NPyBfloat16_ArrFuncs.argmin = NPyBfloat16_ArgMinFunc;

// Py_TYPE has been deprecated since Python 3.9
#if PY_MINOR_VERSION < 9
Py_TYPE(&NPyBfloat16_Descr) = &PyArrayDescr_Type;
#else
Py_SET_TYPE(&NPyBfloat16_Descr, &PyArrayDescr_Type);
#endif

npy_bfloat16 = PyArray_RegisterDataType(&NPyBfloat16_Descr);
bfloat16_type_ptr = &bfloat16_type;
if (npy_bfloat16 < 0)
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def build_extensions(self):

module1 = Extension(PACKAGE_NAME,
sources=['bfloat16.cc'],
include_dirs=[np.get_include()])
include_dirs=[np.get_include()],
extra_compile_args=['-std=c++11'])

setup(name=PACKAGE_NAME,
version='1.1',
Expand Down