rkern / line_profiler

(OLD REPO) Line-by-line profiling for Python - Current repo ->
https://github.com/pyutils/line_profiler
Other
3.6k stars 256 forks source link

build error: 'PyThreadState {aka struct _ts}' has no member named 'exc_type'; did you mean 'curexc_type'? #166

Open Sinan81 opened 4 years ago

Sinan81 commented 4 years ago

getting the build error shown below my setup is:

OS: Centos7 Dependencies were built using Spack: ^py-cython@0.29.7 ^python@3.7.4 ^py-ipython@7.3.0 ^py-backcall@0.1.0 ^py-decorator@4.3.0 ^py-pexpect@4.6.0 ^py-ptyprocess@0.5.1 ^py-pickleshare@0.7.4 ^py-prompt-toolkit@2.0.9 ^py-six@1.12.0 ^py-wcwidth@0.1.7 ^py-pygments@2.3.1 ^py-simplegeneric@0.8.1 ^py-traitlets@4.3.1 ^py-ipython-genutils@0.2.0

==> Installing py-line-profiler
==> Searching for binary cache of py-line-profiler
==> Warning: No Spack mirrors are currently configured
==> No binary for py-line-profiler found: installing from source
==> Using cached archive: /disk/software/lib/hpcpm/spack/var/spack/cache/py-line-profiler/py-line-profiler-2.0.tar.gz
==> Staging archive: /cache/sbulut/spack-stage/py-line-profiler-2.0-5rhvits7zccanvpi6fys7exwzqffo56t/line_profiler-2.0.tar.gz
==> Created stage in /cache/sbulut/spack-stage/py-line-profiler-2.0-5rhvits7zccanvpi6fys7exwzqffo56t
==> No patches needed for py-line-profiler
==> Building py-line-profiler [PythonPackage]
==> Executing phase: 'build'
==> Error: ProcessError: Command exited with status 1:
    '/disk/software/lib/hpcpm/spack/opt/spack/linux-centos7-x86_64/gcc-7.4.0/python-3.7.4-djmvnkbqhmcvxtzgmnbxv7z3as7utxdn/bin/python3.7' '-s' 'setup.py' '--no-user-cfg' 'build'

16 errors found in build log:
     9     running build_ext
     10    skipping '_line_profiler.c' Cython extension (up-to-date)
     11    building '_line_profiler' extension
     12    creating build/temp.linux-x86_64-3.7
     13    /disk/software/lib/hpcpm/spack/lib/spack/env/gcc/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -I/disk/software/lib/hpcpm/spack/opt/spack/linux-centos7-x86_64/gcc-7.
           4.0/python-3.7.4-djmvnkbqhmcvxtzgmnbxv7z3as7utxdn/include/python3.7m -c _line_profiler.c -o build/temp.linux-x86_64-3.7/_line_profiler.o
     14    _line_profiler.c: In function '__Pyx__ExceptionSave':
  >> 15    _line_profiler.c:5478:21: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_type'; did you mean 'curexc_type'?
     16         *type = tstate->exc_type;
     17                         ^~~~~~~~
     18                         curexc_type
  >> 19    _line_profiler.c:5479:22: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_value'; did you mean 'curexc_value'?
     20         *value = tstate->exc_value;
     21                          ^~~~~~~~~
     22                          curexc_value
  >> 23    _line_profiler.c:5480:19: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_traceback'; did you mean 'curexc_traceback'?
     24         *tb = tstate->exc_traceback;
     25                       ^~~~~~~~~~~~~
     26                       curexc_traceback
     27    _line_profiler.c: In function '__Pyx__ExceptionReset':
  >> 28    _line_profiler.c:5487:24: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_type'; did you mean 'curexc_type'?
     29         tmp_type = tstate->exc_type;
     30                            ^~~~~~~~
     31                            curexc_type
  >> 32    _line_profiler.c:5488:25: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_value'; did you mean 'curexc_value'?
     33         tmp_value = tstate->exc_value;
     34                             ^~~~~~~~~
     35                             curexc_value
  >> 36    _line_profiler.c:5489:22: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_traceback'; did you mean 'curexc_traceback'?
     37         tmp_tb = tstate->exc_traceback;
     38                          ^~~~~~~~~~~~~
     39                          curexc_traceback
  >> 40    _line_profiler.c:5490:13: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_type'; did you mean 'curexc_type'?
     41         tstate->exc_type = type;
     42                 ^~~~~~~~
     43                 curexc_type
  >> 44    _line_profiler.c:5491:13: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_value'; did you mean 'curexc_value'?
     45         tstate->exc_value = value;
     46                 ^~~~~~~~~
     47                 curexc_value
  >> 48    _line_profiler.c:5492:13: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_traceback'; did you mean 'curexc_traceback'?
     49         tstate->exc_traceback = tb;
     50                 ^~~~~~~~~~~~~
     51                 curexc_traceback
     52    _line_profiler.c: In function '__Pyx__GetException':
  >> 53    _line_profiler.c:5547:24: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_type'; did you mean 'curexc_type'?
     54         tmp_type = tstate->exc_type;
     55                            ^~~~~~~~
     56                            curexc_type
  >> 57    _line_profiler.c:5548:25: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_value'; did you mean 'curexc_value'?
     58         tmp_value = tstate->exc_value;
     59                             ^~~~~~~~~
     60                             curexc_value
  >> 61    _line_profiler.c:5549:22: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_traceback'; did you mean 'curexc_traceback'?
     62         tmp_tb = tstate->exc_traceback;
     63                          ^~~~~~~~~~~~~
     64                          curexc_traceback
  >> 65    _line_profiler.c:5550:13: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_type'; did you mean 'curexc_type'?
     66         tstate->exc_type = local_type;
     67                 ^~~~~~~~
     68                 curexc_type
  >> 69    _line_profiler.c:5551:13: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_value'; did you mean 'curexc_value'?
     70         tstate->exc_value = local_value;
     71                 ^~~~~~~~~
     72                 curexc_value
  >> 73    _line_profiler.c:5552:13: error: 'PyThreadState {aka struct _ts}' has no member named 'exc_traceback'; did you mean 'curexc_traceback'?
     74         tstate->exc_traceback = local_tb;
     75                 ^~~~~~~~~~~~~
     76                 curexc_traceback
  >> 77    error: command '/disk/software/lib/hpcpm/spack/lib/spack/env/gcc/gcc' failed with exit status 1
teutat3s commented 4 years ago

+1 on macOS with homebrew python 3.7

EDIT: Solution for me was to RTFM read the README.md:

#if needed - pip install Cython
git clone https://github.com/rkern/line_profiler.git
find line_profiler -name '*.pyx' -exec cython {} \;
cd line_profiler
pip install . --user
LBdN commented 4 years ago

The problem is the generated c files that are included in the package. They are generated by cython from pyx/pxd files. But The c api has changed in 3.7 so they need to be rebuild with an up-to-date version cython.

fried commented 4 years ago

Can we get a new source releases on pypi with .c code generated by a more modern cython to support python >=3.7?

It doesn't have to be a new version a .post0 would do it

espdev commented 4 years ago

I think Cython should be added to setup_requires and setup script should compile all Cython files while installation. Distribute pre-compiled Cython files and require the C-compiler anyway... seems it is not a good way. If you distribute your package as binary wheel it should be fully pre-built. If you distribute sources it should be only sources without any pre-built files.

Please see how to add Cython to setup_requires: https://stackoverflow.com/a/38057196/419926