sumerc / yappi

Yet Another Python Profiler, but this time multithreading, asyncio and gevent aware.
MIT License
1.44k stars 72 forks source link

install yappi by pypy #79

Closed jshen28 closed 3 years ago

jshen28 commented 3 years ago

hello, I am trying to install yappi from pypy, but unfortunately got the following error logs,

:~/src/pypy/pypy3.7-v7.3.4-linux64$ ./bin/pypy -mpip install yappi
Collecting yappi
  Using cached yappi-1.3.2.tar.gz (58 kB)
Using legacy setup.py install for yappi, since package 'wheel' is not installed.
Installing collected packages: yappi
    Running setup.py install for yappi ... error
    ERROR: Command errored out with exit status 1:
     command: /home/sjt/src/pypy/pypy3.7-v7.3.4-linux64/bin/pypy -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fh92ib9i/yappi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fh92ib9i/yappi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-6hi_7gfn/install-record.txt --single-version-externally-managed --compile --install-headers /home/sjt/src/pypy/pypy3.7-v7.3.4-linux64/include/yappi
         cwd: /tmp/pip-install-fh92ib9i/yappi/
    Complete output (132 lines):
    /tmp/timer_createq262fzd3.c: In function ‘main’:
    /tmp/timer_createq262fzd3.c:2:5: warning: implicit declaration of function ‘timer_create’ [-Wimplicit-function-declaration]
        2 |     timer_create();
          |     ^~~~~~~~~~~~
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    copying yappi/yappi.py -> build/lib.linux-x86_64-3.7
    running build_ext
    building '_yappi' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/yappi
    gcc -pthread -DNDEBUG -O2 -fPIC -DLIB_RT_AVAILABLE=1 -I/home/sjt/src/pypy/pypy3.7-v7.3.4-linux64/include -c yappi/_yappi.c -o build/temp.linux-x86_64-3.7/yappi/_yappi.o
    yappi/_yappi.c:193: warning: "PyLong_AsVoidPtr" redefined
      193 | #define PyLong_AsVoidPtr (uintptr_t)PyLong_AsVoidPtr
          |
    In file included from /home/sjt/src/pypy/pypy3.7-v7.3.4-linux64/include/Python.h:141,
                     from yappi/config.h:4,
                     from yappi/_yappi.c:10:
    /home/sjt/src/pypy/pypy3.7-v7.3.4-linux64/include/pypy_decl.h:432: note: this is the location of the previous definition
      432 | #define PyLong_AsVoidPtr PyPyLong_AsVoidPtr
          |
    yappi/_yappi.c: In function ‘IS_SUSPENDED’:
    yappi/_yappi.c:222:18: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_stacktop’
      222 |     return (frame->f_stacktop != NULL);
          |                  ^~
    yappi/_yappi.c: In function ‘IS_ASYNC’:
    yappi/_yappi.c:236:50: error: ‘CO_ASYNC_GENERATOR’ undeclared (first use in this function); did you mean ‘CO_GENERATOR’?
      236 |     result = result || frame->f_code->co_flags & CO_ASYNC_GENERATOR;
          |                                                  ^~~~~~~~~~~~~~~~~~
          |                                                  CO_GENERATOR
    yappi/_yappi.c:236:50: note: each undeclared identifier is reported only once for each function it appears in
    yappi/_yappi.c: In function ‘_current_tag’:
    yappi/_yappi.c:193:37: warning: implicit declaration of function ‘PyLong_AsVoidPtr’; did you mean ‘PyPyLong_AsVoidPtr’? [-Wimplicit-function-declaration]
      193 | #define PyLong_AsVoidPtr (uintptr_t)PyLong_AsVoidPtr
          |                                     ^~~~~~~~~~~~~~~~
    yappi/_yappi.c:389:14: note: in expansion of macro ‘PyLong_AsVoidPtr’
      389 |     result = PyLong_AsVoidPtr(r);
          |              ^~~~~~~~~~~~~~~~
    yappi/_yappi.c: In function ‘_code2pit’:
    yappi/_yappi.c:657:23: error: ‘PyCodeObject’ {aka ‘struct <anonymous>’} has no member named ‘co_firstlineno’
      657 |     pit->lineno = cobj->co_firstlineno;
          |                       ^~
    yappi/_yappi.c:661:5: warning: implicit declaration of function ‘PyFrame_FastToLocals’ [-Wimplicit-function-declaration]
      661 |     PyFrame_FastToLocals(fobj);
          |     ^~~~~~~~~~~~~~~~~~~~
    yappi/_yappi.c:663:72: error: ‘PyCodeObject’ {aka ‘struct <anonymous>’} has no member named ‘co_varnames’; did you mean ‘co_name’?
      663 |         const char *firstarg = PyStr_AS_CSTRING(PyTuple_GET_ITEM(cobj->co_varnames, 0));
          |                                                                        ^~~~~~~~~~~
    yappi/_yappi.c:182:46: note: in definition of macro ‘PyStr_AS_CSTRING’
      182 | #define PyStr_AS_CSTRING(s) PyUnicode_AsUTF8(s)
          |                                              ^
    yappi/_yappi.c:663:49: note: in expansion of macro ‘PyTuple_GET_ITEM’
      663 |         const char *firstarg = PyStr_AS_CSTRING(PyTuple_GET_ITEM(cobj->co_varnames, 0));
          |                                                 ^~~~~~~~~~~~~~~~
    yappi/_yappi.c:688:5: warning: implicit declaration of function ‘PyFrame_LocalsToFast’ [-Wimplicit-function-declaration]
      688 |     PyFrame_LocalsToFast(fobj, 0);
          |     ^~~~~~~~~~~~~~~~~~~~
    yappi/_yappi.c: In function ‘_yapp_callback’:
    yappi/_yappi.c:1181:10: error: ‘PyTrace_CALL’ undeclared (first use in this function)
     1181 |     case PyTrace_CALL:
          |          ^~~~~~~~~~~~
    yappi/_yappi.c:1184:10: error: ‘PyTrace_RETURN’ undeclared (first use in this function)
     1184 |     case PyTrace_RETURN: // either normally or with an exception
          |          ^~~~~~~~~~~~~~
    yappi/_yappi.c:1192:10: error: ‘PyTrace_C_CALL’ undeclared (first use in this function)
     1192 |     case PyTrace_C_CALL:
          |          ^~~~~~~~~~~~~~
    yappi/_yappi.c:1197:10: error: ‘PyTrace_C_RETURN’ undeclared (first use in this function)
     1197 |     case PyTrace_C_RETURN:
          |          ^~~~~~~~~~~~~~~~
    yappi/_yappi.c:1198:10: error: ‘PyTrace_C_EXCEPTION’ undeclared (first use in this function)
     1198 |     case PyTrace_C_EXCEPTION:
          |          ^~~~~~~~~~~~~~~~~~~
    yappi/_yappi.c: In function ‘_bootstrap_thread’:
    yappi/_yappi.c:1261:7: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘use_tracing’
     1261 |     ts->use_tracing = 1;
          |       ^~
    yappi/_yappi.c:1262:7: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘c_profilefunc’
     1262 |     ts->c_profilefunc = _yapp_callback;
          |       ^~
    yappi/_yappi.c: In function ‘_profile_thread’:
    yappi/_yappi.c:1292:7: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘use_tracing’
     1292 |     ts->use_tracing = 1;
          |       ^~
    yappi/_yappi.c:1293:7: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘c_profilefunc’
     1293 |     ts->c_profilefunc = _yapp_callback;
          |       ^~
    yappi/_yappi.c:1295:18: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘thread_id’
     1295 |     ctx->tid = ts->thread_id;
          |                  ^~
    yappi/_yappi.c: In function ‘_unprofile_thread’:
    yappi/_yappi.c:1309:7: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘use_tracing’
     1309 |     ts->use_tracing = 0;
          |       ^~
    yappi/_yappi.c:1310:7: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘c_profilefunc’
     1310 |     ts->c_profilefunc = NULL;
          |       ^~
    yappi/_yappi.c: In function ‘_ensure_thread_profiled’:
    yappi/_yappi.c:1318:11: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘c_profilefunc’
     1318 |     if (ts->c_profilefunc != _yapp_callback)
          |           ^~
    yappi/_yappi.c: In function ‘_enum_threads’:
    yappi/_yappi.c:1330:17: warning: implicit declaration of function ‘PyInterpreterState_ThreadHead’; did you mean ‘PyInterpreterState_Head’? [-Wimplicit-function-declaration]
     1330 |         for (ts=PyInterpreterState_ThreadHead(is) ; ts != NULL; ts = ts->next) {
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                 PyInterpreterState_Head
    yappi/_yappi.c:1330:16: warning: assignment to ‘PyThreadState *’ {aka ‘struct _ts *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
     1330 |         for (ts=PyInterpreterState_ThreadHead(is) ; ts != NULL; ts = ts->next) {
          |                ^
    yappi/_yappi.c:1330:72: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘next’
     1330 |         for (ts=PyInterpreterState_ThreadHead(is) ; ts != NULL; ts = ts->next) {
          |                                                                        ^~
    yappi/_yappi.c: In function ‘profile_event’:
    yappi/_yappi.c:1396:37: error: ‘PyTrace_CALL’ undeclared (first use in this function)
     1396 |         _yapp_callback(self, frame, PyTrace_CALL, arg);
          |                                     ^~~~~~~~~~~~
    yappi/_yappi.c:1398:37: error: ‘PyTrace_RETURN’ undeclared (first use in this function)
     1398 |         _yapp_callback(self, frame, PyTrace_RETURN, arg);
          |                                     ^~~~~~~~~~~~~~
    yappi/_yappi.c:1400:37: error: ‘PyTrace_C_CALL’ undeclared (first use in this function)
     1400 |         _yapp_callback(self, frame, PyTrace_C_CALL, arg);
          |                                     ^~~~~~~~~~~~~~
    yappi/_yappi.c:1402:37: error: ‘PyTrace_C_RETURN’ undeclared (first use in this function)
     1402 |         _yapp_callback(self, frame, PyTrace_C_RETURN, arg);
          |                                     ^~~~~~~~~~~~~~~~
    yappi/_yappi.c:1404:37: error: ‘PyTrace_C_EXCEPTION’ undeclared (first use in this function)
     1404 |         _yapp_callback(self, frame, PyTrace_C_EXCEPTION, arg);
          |                                     ^~~~~~~~~~~~~~~~~~~
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/sjt/src/pypy/pypy3.7-v7.3.4-linux64/bin/pypy -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fh92ib9i/yappi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fh92ib9i/yappi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-6hi_7gfn/install-record.txt --single-version-externally-managed --compile --install-headers /home/sjt/src/pypy/pypy3.7-v7.3.4-linux64/include/yappi Check the logs for full command output.

any idea how to fix it? thank you

sumerc commented 3 years ago

Hello! Currently yappi does not support pypy it only supports CPython interpreter.

ctrahey commented 2 years ago

@sumerc I see the same issue on CPython (3.10.0rc1)

This is on Apple M1

(3ten) ctrahey@ChristophersMBP foo % python -c "import platform; print(platform.python_implementation())"
CPython
(3ten) ctrahey@ChristophersMBP foo % python -V
Python 3.10.0rc1

(3ten) ctrahey@ChristophersMBP foo % python -m pip install --no-cache-dir yappi            
Collecting yappi
  Downloading yappi-1.3.2.tar.gz (58 kB)
     |████████████████████████████████| 58 kB 2.7 MB/s 
Building wheels for collected packages: yappi
  Building wheel for yappi (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/ctrahey/.pyenv/versions/3ten/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-install-7k6gtf97/yappi_2a59af5e929c4a3a976c0090b386ac9f/setup.py'"'"'; __file__='"'"'/private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-install-7k6gtf97/yappi_2a59af5e929c4a3a976c0090b386ac9f/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 /private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-wheel-rrt68x6w
       cwd: /private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-install-7k6gtf97/yappi_2a59af5e929c4a3a976c0090b386ac9f/
  Complete output (22 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-11.3-arm64-3.10
  copying yappi/yappi.py -> build/lib.macosx-11.3-arm64-3.10
  running build_ext
  building '_yappi' extension
  creating build/temp.macosx-11.3-arm64-3.10
  creating build/temp.macosx-11.3-arm64-3.10/yappi
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Users/ctrahey/.pyenv/versions/3ten/include -I/Users/ctrahey/.pyenv/versions/3.10.0rc1/include/python3.10 -c yappi/_yappi.c -o build/temp.macosx-11.3-arm64-3.10/yappi/_yappi.o
  yappi/_yappi.c:1261:9: error: no member named 'use_tracing' in 'struct _ts'
      ts->use_tracing = 1;
      ~~  ^
  yappi/_yappi.c:1292:9: error: no member named 'use_tracing' in 'struct _ts'
      ts->use_tracing = 1;
      ~~  ^
  yappi/_yappi.c:1309:9: error: no member named 'use_tracing' in 'struct _ts'
      ts->use_tracing = 0;
      ~~  ^
  3 errors generated.
  error: command '/usr/bin/clang' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for yappi
  Running setup.py clean for yappi
Failed to build yappi
Installing collected packages: yappi
    Running setup.py install for yappi ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/ctrahey/.pyenv/versions/3ten/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-install-7k6gtf97/yappi_2a59af5e929c4a3a976c0090b386ac9f/setup.py'"'"'; __file__='"'"'/private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-install-7k6gtf97/yappi_2a59af5e929c4a3a976c0090b386ac9f/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'"'"'))' install --record /private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-record-d9e1e4fa/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ctrahey/.pyenv/versions/3ten/include/site/python3.10/yappi
         cwd: /private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-install-7k6gtf97/yappi_2a59af5e929c4a3a976c0090b386ac9f/
    Complete output (22 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-11.3-arm64-3.10
    copying yappi/yappi.py -> build/lib.macosx-11.3-arm64-3.10
    running build_ext
    building '_yappi' extension
    creating build/temp.macosx-11.3-arm64-3.10
    creating build/temp.macosx-11.3-arm64-3.10/yappi
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Users/ctrahey/.pyenv/versions/3ten/include -I/Users/ctrahey/.pyenv/versions/3.10.0rc1/include/python3.10 -c yappi/_yappi.c -o build/temp.macosx-11.3-arm64-3.10/yappi/_yappi.o
    yappi/_yappi.c:1261:9: error: no member named 'use_tracing' in 'struct _ts'
        ts->use_tracing = 1;
        ~~  ^
    yappi/_yappi.c:1292:9: error: no member named 'use_tracing' in 'struct _ts'
        ts->use_tracing = 1;
        ~~  ^
    yappi/_yappi.c:1309:9: error: no member named 'use_tracing' in 'struct _ts'
        ts->use_tracing = 0;
        ~~  ^
    3 errors generated.
    error: command '/usr/bin/clang' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/ctrahey/.pyenv/versions/3ten/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-install-7k6gtf97/yappi_2a59af5e929c4a3a976c0090b386ac9f/setup.py'"'"'; __file__='"'"'/private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-install-7k6gtf97/yappi_2a59af5e929c4a3a976c0090b386ac9f/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'"'"'))' install --record /private/var/folders/p_/32g2_q1x46vc7rprbnklt5c40000gn/T/pip-record-d9e1e4fa/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ctrahey/.pyenv/versions/3ten/include/site/python3.10/yappi Check the logs for full command output.
ctrahey commented 2 years ago

This looks like the breaking change, but might be an easy fix: use_tracing has moved to a new struct called cframe, and this _ts struct has replaced use_tracing with a pointer to this new cframe type.

EKivutha commented 2 years ago

Hello! Currently yappi does not support pypy it only supports CPython interpreter.

Hey tried installing Cpython then yappi but the issue still persists, this is on Windows