TA-Lib / ta-lib-python

Python wrapper for TA-Lib (http://ta-lib.org/).
http://ta-lib.github.io/ta-lib-python
Other
9.27k stars 1.72k forks source link

Mismatch of func declaration #489

Open piotr5151 opened 2 years ago

piotr5151 commented 2 years ago

I have a problem to install ta-lib wrapper in linux machine over ta-lib compiled from source code. I found out a mismatch between functions.

there is an error: /usr/include/ta-lib/ta_abstract.h:155:52: note: expected ‘const TA_FuncHandle **’ {aka ‘const unsigned int **’} but argument is of type ‘TA_FuncHandle **’ {aka ‘unsigned int **’}

I've checked the files and indeed ta_abstract.h declares the function as const, but talib/_ta_lib.c declares as non-const. There are 3 more mistakes in the file.

mrjbq7 commented 2 years ago

Which are the other 3 mistakes?

mrjbq7 commented 2 years ago

Does this prevent it from working? Or is it just a warning?

piotr5151 commented 2 years ago

It is error not warning and pip cannot compile the wrapper.

mrjbq7 commented 2 years ago

Which compiler are you using?

I’ve not seen that error preventing builds before. We run tests on macOS, linux, and windows.

On Jan 8, 2022, at 11:34 AM, piotr5151 @.***> wrote:

 It is error not warning and pip cannot compile the wrapper.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.

trufanov-nok commented 2 years ago

That might be bcs of a new gcc compiler version. I faced with an error which recently was only a warning in some other project (can't remember which) bcs of that. upd: and mine was gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0 (Kubuntu 21.10)

mrjbq7 commented 2 years ago

I looked through and added const in all the places I recognized.

Can you try latest git master and see if it works for you?

If it doesn't can you attach some output so I can see what is failing?

mrjbq7 commented 2 years ago

https://github.com/mrjbq7/ta-lib/commit/863d88a5a6ebd90b98faa58d3b42d3130aeb9165

piotr5151 commented 2 years ago
unfortunately it doesn't work ` ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/ta-wrapper/ta-lib/setup.py'"'"'; file='"'"'/ta-wrapper/ta-lib/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-84symm7a cwd: /ta-wrapper/ta-lib/ Complete output (65 lines): running bdist_wheel running build running build_py running build_ext x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/opt/homebrew/include -I/opt/homebrew/opt/ta-lib/include -I/usr/local/lib/python3.8/dist-packages/numpy/core/include -I/usr/include/python3.8 -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.8/talib/_ta_lib.o In file included from /usr/local/lib/python3.8/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1969, from /usr/local/lib/python3.8/dist-packages/numpy/core/include/numpy/ndarrayobject.h:12, from /usr/local/lib/python3.8/dist-packages/numpy/core/include/numpy/arrayobject.h:4, from talib/_ta_lib.c:689: /usr/local/lib/python3.8/dist-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] 17 #warning "Using deprecated NumPy API, disable it with " \ ^~~ talib/_ta_lib.c: In function ‘__pyx_pf_5talib_7_ta_lib_348_ta_getFuncInfo’: talib/_ta_lib.c:38706:104: warning: passing argument 2 of ‘TA_GetFuncInfo’ from incompatible pointer type [-Wincompatible-pointer-types] 38706 pyx_v_retCode = TA_GetFuncInfo(pyx_f_5talib_7_talibta_getFuncHandle(pyx_v_function_name), (&__pyx_v_info)); ~^~~~~~
TA_FuncInfo {aka struct TA_FuncInfo }
In file included from talib/_ta_lib.c:684: /usr/include/ta-lib/ta_abstract.h:211:48: note: expected ‘const TA_FuncInfo ’ {aka ‘const struct TA_FuncInfo ’} but argument is of type ‘TA_FuncInfo ’ {aka ‘struct TA_FuncInfo ’} 211 const TA_FuncInfo **funcInfo ); ~~~~^~~~ talib/_ta_lib.c: In function ‘__pyx_pf_5talib_7_ta_lib_350_ta_getInputParameterInfo’: talib/_ta_lib.c:38977:127: warning: passing argument 3 of ‘TA_GetInputParameterInfo’ from incompatible pointer type [-Wincompatible-pointer-types] 38977 pyx_v_retCode = TA_GetInputParameterInfo(pyx_f_5talib_7_talibta_getFuncHandle(pyx_v_function_name), pyx_v_idx, (&pyx_v_info)); ~^~~~~~
TA_InputParameterInfo {aka struct TA_InputParameterInfo }
In file included from talib/_ta_lib.c:684: /usr/include/ta-lib/ta_abstract.h:442:68: note: expected ‘const TA_InputParameterInfo ’ {aka ‘const struct TA_InputParameterInfo ’} but argument is of type ‘TA_InputParameterInfo ’ {aka ‘struct TA_InputParameterInfo ’} 442 const TA_InputParameterInfo **info ); ~~~~~~^~~~ talib/_ta_lib.c: In function ‘__pyx_pf_5talib_7_ta_lib_352_ta_getOptInputParameterInfo’: talib/_ta_lib.c:39227:130: warning: passing argument 3 of ‘TA_GetOptInputParameterInfo’ from incompatible pointer type [-Wincompatible-pointer-types] 39227 pyx_v_retCode = TA_GetOptInputParameterInfo(pyx_f_5talib_7_talibta_getFuncHandle(pyx_v_function_name), pyx_v_idx, (&pyx_v_info)); ~^~~~~~
TA_OptInputParameterInfo {aka struct TA_OptInputParameterInfo }
In file included from talib/_ta_lib.c:684: /usr/include/ta-lib/ta_abstract.h:446:74: note: expected ‘const TA_OptInputParameterInfo ’ {aka ‘const struct TA_OptInputParameterInfo ’} but argument is of type ‘TA_OptInputParameterInfo ’ {aka ‘struct TA_OptInputParameterInfo ’} 446 const TA_OptInputParameterInfo **info ); ~~~~~~~^~ talib/_ta_lib.c: In function ‘__pyx_pf_5talib_7_ta_lib_354_ta_getOutputParameterInfo’: talib/_ta_lib.c:39473:128: warning: passing argument 3 of ‘TA_GetOutputParameterInfo’ from incompatible pointer type [-Wincompatible-pointer-types] 39473 pyx_v_retCode = TA_GetOutputParameterInfo(pyx_f_5talib_7_talibta_getFuncHandle(pyx_v_function_name), pyx_v_idx, (&pyx_v_info)); ~^~~~~~
TA_OutputParameterInfo {aka struct TA_OutputParameterInfo }
In file included from talib/_ta_lib.c:684: /usr/include/ta-lib/ta_abstract.h:450:70: note: expected ‘const TA_OutputParameterInfo ’ {aka ‘const struct TA_OutputParameterInfo ’} but argument is of type ‘TA_OutputParameterInfo ’ {aka ‘struct TA_OutputParameterInfo ’} 450 const TA_OutputParameterInfo **info ); ~~~~~~~^~~~ talib/_ta_lib.c: In function ‘pyx_f_5talib_7_talibta_getFuncHandle’: talib/_ta_lib.c:40072:126: warning: passing argument 2 of ‘TA_GetFuncHandle’ from incompatible pointer type [-Wincompatible-pointer-types] 40072 pyx_t_1 = pyx_f_5talib_7_ta_libta_check_success(pyx_n_s_TA_GetFuncHandle, TA_GetFuncHandle(pyx_v_function_name, (&pyx_v_handle)), 0); if (unlikely(!pyx_t_1)) __PYX_ERR(1, 751, pyx_L1_error) ~^~~~
TA_FuncHandle {aka unsigned int }

In file included from talib/_ta_lib.c:684: /usr/include/ta-lib/ta_abstract.h:155:52: note: expected ‘const TA_FuncHandle ’ {aka ‘const unsigned int ’} but argument is of type ‘TA_FuncHandle ’ {aka ‘unsigned int ’} 155 | const TA_FuncHandle **handle ); | ~~~~^~~~ x86_64-linux-gnu-gcc: fatal error: Killed signal terminated program cc1 compilation terminated. error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1`

mrjbq7 commented 2 years ago

This doesn’t look like the warnings are breaking it.

It looks like you don’t have enough memory and compile fails. Are you using 1GB?

I’ve seen this before;

x86_64-linux-gnu-gcc: fatal error: Killed signal terminated program cc1 compilation terminated. error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

On Jan 12, 2022, at 8:11 AM, piotr5151 @.***> wrote:

 unfortunately it doesn't work ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/ta-wrapper/ta-lib/setup.py'"'"'; file='"'"'/ta-wrapper/ta-lib/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-84symm7a cwd: /ta-wrapper/ta-lib/ Complete output (65 lines): running bdist_wheel running build running build_py running build_ext x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/opt/homebrew/include -I/opt/homebrew/opt/ta-lib/include -I/usr/local/lib/python3.8/dist-packages/numpy/core/include -I/usr/include/python3.8 -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.8/talib/_ta_lib.o In file included from /usr/local/lib/python3.8/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1969, from /usr/local/lib/python3.8/dist-packages/numpy/core/include/numpy/ndarrayobject.h:12, from /usr/local/lib/python3.8/dist-packages/numpy/core/include/numpy/arrayobject.h:4, from talib/_ta_lib.c:689: /usr/local/lib/python3.8/dist-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] 17 | #warning "Using deprecated NumPy API, disable it with " \ | ^~~ talib/_ta_lib.c: In function ‘pyx_pf_5talib_7_ta_lib_348_ta_getFuncInfo’: talib/_ta_lib.c:38706:104: warning: passing argument 2 of ‘TA_GetFuncInfo’ from incompatible pointer type [-Wincompatible-pointer-types] 38706 | __pyx_v_retCode = TA_GetFuncInfo(pyx_f_5talib_7_ta_lib_ta_getFuncHandle(pyx_v_function_name), (&pyx_v_info)); | ~^~~~ | | | TA_FuncInfo {aka struct TA_FuncInfo } In file included from talib/_ta_lib.c:684: /usr/include/ta-lib/ta_abstract.h:211:48: note: expected ‘const TA_FuncInfo ’ {aka ‘const struct TA_FuncInfo ’} but argument is of type ‘TA_FuncInfo ’ {aka ‘struct TA_FuncInfo ’} 211 | const TA_FuncInfo **funcInfo ); | ~~~~^~ talib/_ta_lib.c: In function ‘pyx_pf_5talib_7_ta_lib_350_ta_getInputParameterInfo’: talib/_ta_lib.c:38977:127: warning: passing argument 3 of ‘TA_GetInputParameterInfo’ from incompatible pointer type [-Wincompatible-pointer-types] 38977 | pyx_v_retCode = TA_GetInputParameterInfo(pyx_f_5talib_7_talibta_getFuncHandle(pyx_v_function_name), pyx_v_idx, (&pyx_v_info)); | ~^~~~ | | | TA_InputParameterInfo {aka struct TA_InputParameterInfo } In file included from talib/_ta_lib.c:684: /usr/include/ta-lib/ta_abstract.h:442:68: note: expected ‘const TA_InputParameterInfo ’ {aka ‘const struct TA_InputParameterInfo ’} but argument is of type ‘TA_InputParameterInfo ’ {aka ‘struct TA_InputParameterInfo ’} 442 | const TA_InputParameterInfo **info ); | ~~~~~~^~ talib/_ta_lib.c: In function ‘pyx_pf_5talib_7_ta_lib_352_ta_getOptInputParameterInfo’: talib/_ta_lib.c:39227:130: warning: passing argument 3 of ‘TA_GetOptInputParameterInfo’ from incompatible pointer type [-Wincompatible-pointer-types] 39227 | __pyx_v_retCode = TA_GetOptInputParameterInfo(pyx_f_5talib_7_ta_lib_ta_getFuncHandle(pyx_v_function_name), pyx_v_idx, (&pyx_v_info)); | ~^~~~ | | | TA_OptInputParameterInfo {aka struct TA_OptInputParameterInfo } In file included from talib/_ta_lib.c:684: /usr/include/ta-lib/ta_abstract.h:446:74: note: expected ‘const TA_OptInputParameterInfo ’ {aka ‘const struct TA_OptInputParameterInfo ’} but argument is of type ‘TA_OptInputParameterInfo ’ {aka ‘struct TA_OptInputParameterInfo ’} 446 | const TA_OptInputParameterInfo **info ); | ~~~~~~~^~ talib/_ta_lib.c: In function ‘pyx_pf_5talib_7_ta_lib_354_ta_getOutputParameterInfo’: talib/_ta_lib.c:39473:128: warning: passing argument 3 of ‘TA_GetOutputParameterInfo’ from incompatible pointer type [-Wincompatible-pointer-types] 39473 | __pyx_v_retCode = TA_GetOutputParameterInfo(pyx_f_5talib_7_ta_lib_ta_getFuncHandle(pyx_v_function_name), pyx_v_idx, (&pyx_v_info)); | ~^~~~ | | | TA_OutputParameterInfo {aka struct TA_OutputParameterInfo } In file included from talib/_ta_lib.c:684: /usr/include/ta-lib/ta_abstract.h:450:70: note: expected ‘const TA_OutputParameterInfo ’ {aka ‘const struct TA_OutputParameterInfo ’} but argument is of type ‘TA_OutputParameterInfo ’ {aka ‘struct TA_OutputParameterInfo ’} 450 | const TA_OutputParameterInfo info ); | ~~~~~~~^~ talib/_ta_lib.c: In function ‘pyx_f_5talib_7_talibta_getFuncHandle’: talib/_ta_lib.c:40072:126: warning: passing argument 2 of ‘TA_GetFuncHandle’ from incompatible pointer type [-Wincompatible-pointer-types] 40072 | pyx_t_1 = pyx_f_5talib_7_ta_libta_check_success(pyx_n_s_TA_GetFuncHandle, TA_GetFuncHandle(pyx_v_function_name, (&pyx_v_handle)), 0); if (unlikely(!pyx_t_1)) __PYX_ERR(1, 751, pyx_L1_error) | ~^~~~~~ | | | TA_FuncHandle {aka unsigned int } In file included from talib/_ta_lib.c:684: /usr/include/ta-lib/ta_abstract.h:155:52: note: expected ‘const TA_FuncHandle ’ {aka ‘const unsigned int ’} but argument is of type ‘TA_FuncHandle ’ {aka ‘unsigned int ’} 155 | const TA_FuncHandle handle ); | ~~~~^~~~ x86_64-linux-gnu-gcc: fatal error: Killed signal terminated program cc1 compilation terminated. error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.

MattBJ commented 2 months ago

I am happy to announce I have fixed the compiler error on my end. I was getting the same errors. There are multiple pointer references __pyx_v_handle in the talib/_ta_lib.c file that are not const when they need to be.

It's a bit confusing for me to decipher with git diff | grep '__pyx_v_handle', maybe it's having a struggle with the large generated source file. I'll try and copy the sections I changed here.

static TA_FuncHandle *__pyx_f_5talib_7_ta_lib___ta_getFuncHandle(char *__pyx_v_function_name) {
  TA_FuncHandle *__pyx_v_handle; // needs to be a const pointer
...
static PyObject *__pyx_pf_5talib_7_ta_lib_354_ta_getOutputParameterInfo(CYTHON_UNUSED PyObject *__pyx_self, char *__pyx_v_function_name, int __pyx_v_idx) {
  TA_OutputParameterInfo *__pyx_v_info; // needs to be a const pointer
...
static PyObject *__pyx_pf_5talib_7_ta_lib_352_ta_getOptInputParameterInfo(CYTHON_UNUSED PyObject *__pyx_self, char *__pyx_v_function_name, int __pyx_v_idx) {
  TA_OptInputParameterInfo *__pyx_v_info; // needs to be a const pointer
...
static PyObject *__pyx_pf_5talib_7_ta_lib_350_ta_getInputParameterInfo(CYTHON_UNUSED PyObject *__pyx_self, char *__pyx_v_function_name, int __pyx_v_idx) {
  TA_InputParameterInfo *__pyx_v_info; // needs to be a const pointer
...
static PyObject *__pyx_pf_5talib_7_ta_lib_348_ta_getFuncInfo(CYTHON_UNUSED PyObject *__pyx_self, char *__pyx_v_function_name) {
  TA_FuncInfo *__pyx_v_info; // can you guess what this needs to be?

Changing those allowed the python setup.py install to run properly, and I've also tested with pip install /path/to/my/cloned/version

gcc --version = gcc (GCC) 14.0.1 20240411 (Red Hat 14.0.1-0)

mrjbq7 commented 2 months ago

We generate _ta_lib.c from a cython file, perhaps there's a way to make cython generate better C code... I'd sort of rather not post-process the cython output but we could...

MattBJ commented 2 months ago

I have no real understanding of the cython generation process, but generally I would agree with you that it's ideal to solve the problem in the generation process itself. The differences in platform/environment could affect different users in unique ways, which is also why I provided my gcc version. Maybe there's more information that could be collected to narrow it down. I presume there is no issue with the const declarations in your own local repos.

mrjbq7 commented 2 months ago

Fixed const pointer compares in e829cdaca3cbdfd91854a4f4716bffcdc22d756a.

I'm still seeing a few warnings:

/opt/homebrew/lib/python3.11/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with "          "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it with " \
 ^
talib/_ta_lib.c:103574:21: warning: fallthrough annotation in unreachable code [-Wunreachable-code-fallthrough]
                    CYTHON_FALLTHROUGH;
                    ^
talib/_ta_lib.c:544:34: note: expanded from macro 'CYTHON_FALLTHROUGH'
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
                                 ^
talib/_ta_lib.c:103585:21: warning: fallthrough annotation in unreachable code [-Wunreachable-code-fallthrough]
                    CYTHON_FALLTHROUGH;
                    ^
talib/_ta_lib.c:544:34: note: expanded from macro 'CYTHON_FALLTHROUGH'
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
                                 ^
talib/_ta_lib.c:103983:21: warning: fallthrough annotation in unreachable code [-Wunreachable-code-fallthrough]
                    CYTHON_FALLTHROUGH;
                    ^
talib/_ta_lib.c:544:34: note: expanded from macro 'CYTHON_FALLTHROUGH'
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
                                 ^
talib/_ta_lib.c:103994:21: warning: fallthrough annotation in unreachable code [-Wunreachable-code-fallthrough]
                    CYTHON_FALLTHROUGH;
                    ^
talib/_ta_lib.c:544:34: note: expanded from macro 'CYTHON_FALLTHROUGH'
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
                                 ^
5 warnings generated.