hlin117 / mdlp-discretization

An implementation of the minimum description length principal expert binning algorithm by Usama Fayyad
BSD 3-Clause "New" or "Revised" License
101 stars 54 forks source link

Compile error on MacOS with gcc error #34

Open anilkumarpanda opened 5 years ago

anilkumarpanda commented 5 years ago

Unable to compile the package on MacOS with the following error message .

warning: "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]

warning "Using deprecated NumPy API, disable it by " \

 ^
mdlp/_mdlp.cpp:542:10: fatal error: 'utility' file not found
#include <utility>
         ^~~~~~~~~
2 warnings and 1 error generated.
error: command 'gcc' failed with exit status 1
FelixNeutatz commented 5 years ago

I get a similar error on Ubuntu

ython3.7/site-packages/numpy/core/include -c mdlp/_mdlp.cpp -o build/temp.linux-x86_64-3.7/mdlp/_mdlp.o
In file included from /home/felix/FastFeatures/new_project/venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822:0,
                 from /home/felix/FastFeatures/new_project/venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                 from /home/felix/FastFeatures/new_project/venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from mdlp/_mdlp.cpp:539:
/home/felix/FastFeatures/new_project/venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it with " \
  ^
mdlp/_mdlp.cpp: In function ‘void __Pyx__ExceptionSave(PyThreadState*, PyObject**, PyObject**, PyObject**)’:
mdlp/_mdlp.cpp:9095:21: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’
     *type = tstate->exc_type;
                     ^
mdlp/_mdlp.cpp:9096:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’
     *value = tstate->exc_value;
                      ^
mdlp/_mdlp.cpp:9097:19: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’
     *tb = tstate->exc_traceback;
                   ^
mdlp/_mdlp.cpp: In function ‘void __Pyx__ExceptionReset(PyThreadState*, PyObject*, PyObject*, PyObject*)’:
mdlp/_mdlp.cpp:9104:24: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’
     tmp_type = tstate->exc_type;
                        ^
mdlp/_mdlp.cpp:9105:25: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’
     tmp_value = tstate->exc_value;
                         ^
mdlp/_mdlp.cpp:9106:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’
     tmp_tb = tstate->exc_traceback;
                      ^
mdlp/_mdlp.cpp:9107:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’
     tstate->exc_type = type;
             ^
mdlp/_mdlp.cpp:9108:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’
     tstate->exc_value = value;
             ^
mdlp/_mdlp.cpp:9109:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’
     tstate->exc_traceback = tb;
             ^
mdlp/_mdlp.cpp: In function ‘int __Pyx__GetException(PyThreadState*, PyObject**, PyObject**, PyObject**)’:
mdlp/_mdlp.cpp:9179:24: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’
     tmp_type = tstate->exc_type;
                        ^
mdlp/_mdlp.cpp:9180:25: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’
     tmp_value = tstate->exc_value;
                         ^
mdlp/_mdlp.cpp:9181:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’
     tmp_tb = tstate->exc_traceback;
                      ^
mdlp/_mdlp.cpp:9182:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’
     tstate->exc_type = local_type;
             ^
mdlp/_mdlp.cpp:9183:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’
     tstate->exc_value = local_value;
             ^
mdlp/_mdlp.cpp:9184:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’
     tstate->exc_traceback = local_tb;
             ^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
daanknoope commented 1 year ago

@FelixNeutatz's issue seems to be caused by an incompatibility between Cython 0.27.2 (which is used to compile _mdlp.cpp and Python>3.6 (see: https://github.com/mcfletch/pyopengl/issues/11).

Since Python 3.6 is EOL, most people will install this package with a version higher than that. However, the precompiled _mdlp.cpp has been created by a Cython version that is no longer supported in Python versions greater than 3.6.

To fix this problem, two approaches are possible:

  1. Before you install this package, install cython in your environment. setup.py will notice Cython being installed, and will automatically recompile the cpp dependency for your latest version.
  2. You can use a recompiled version of this package that has a newer version of _mdlp.cpp. I have created PR which you can use for this. I will also create a PR to update it in this repository, since nobody should be using Python3.6 anymore.