sumerc / yappi

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

Can't install on macOS #138

Closed aaarrti closed 1 year ago

aaarrti commented 1 year ago

Hi there,

I'm facing problems with installation on M1 mac, with OS version 13.2 (22D49).

Collecting yappi
  Using cached yappi-1.4.0.tar.gz (59 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: yappi
  Building wheel for yappi (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for yappi (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-13-arm64-cpython-311
      copying yappi/yappi.py -> build/lib.macosx-13-arm64-cpython-311
      running build_ext
      building '_yappi' extension
      creating build/temp.macosx-13-arm64-cpython-311
      creating build/temp.macosx-13-arm64-cpython-311/yappi
      clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c yappi/_yappi.c -o build/temp.macosx-13-arm64-cpython-311/yappi/_yappi.o
      In file included from yappi/_yappi.c:10:
      In file included from yappi/config.h:4:
      In file included from /opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11/Python.h:36:
      /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/wchar.h:89:10: fatal error: 'stdarg.h' file not found
      #include <stdarg.h>
               ^~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for yappi
Failed to build yappi
ERROR: Could not build wheels for yappi, which is required to install pyproject.toml-based projects

This is the output of clang --version

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I have tried all python versions, starting 3.8 up to 3.11, all failed. I am using anaconda to manage virtual envs, so I naturally though this is the reason for the missing headers, so I tried using the system interpreter (3.9.6), and it also failed. Then I tried to use Rosetta like arch -x86_64 python3 -m pip install yappi, and this one worked!

So, I suppose the actual issue is the difference between AMD and ARM-specific headers? Do you have any ideas how to use yappi on ARM? Is this a know issue?

ejohnson01 commented 1 year ago

I also was not able to install in a docker container I was building for arm. I guess yappi isn't supported on arm yet.

aaarrti commented 1 year ago

ok, it turns out my installation of clang was broken. Running

sudo rm -rf /library/Developer/CommandLineTools
xcode-select --install

resolved the issue.