kcl-lang / kcl-py

KCL Python SDK
Apache License 2.0
9 stars 5 forks source link

error occurred when install kclvm-py on mac M1 #2

Closed amyXia1994 closed 1 year ago

amyXia1994 commented 1 year ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

I run this command to install kclvm-py: python3 -m pip install kclvm && python3 -m kclvm --help

and it failed when installing required package cffi:

Building wheels for collected packages: cffi
    Building wheel for cffi (setup.py): started
    Building wheel for cffi (setup.py): finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/bz/9gzt5_xn37ng7km3wmtqbfzh0000gp/T/pip-install-crjb827d/cffi/setup.py'"'"'; __file__='"'"'/private/var/folders/bz/9gzt5_xn37ng7km3wmtqbfzh0000gp/T/pip-install-crjb827d/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/bz/9gzt5_xn37ng7km3wmtqbfzh0000gp/T/pip-wheel-r7f5bayo
         cwd: /private/var/folders/bz/9gzt5_xn37ng7km3wmtqbfzh0000gp/T/pip-install-crjb827d/cffi/
    Complete output (37 lines):
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14-arm64-3.8
    creating build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/backend_ctypes.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/error.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/setuptools_ext.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/__init__.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/cffi_opcode.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/vengine_gen.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/pkgconfig.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/model.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/ffiplatform.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/api.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/vengine_cpy.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/commontypes.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/lock.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/recompiler.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/cparser.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/verifier.py -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/_cffi_include.h -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/parse_c_type.h -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/_embedding.h -> build/lib.macosx-10.14-arm64-3.8/cffi
    copying cffi/_cffi_errors.h -> build/lib.macosx-10.14-arm64-3.8/cffi
    running build_ext
    building '_cffi_backend' extension
    creating build/temp.macosx-10.14-arm64-3.8
    creating build/temp.macosx-10.14-arm64-3.8/c
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/opt/homebrew/opt/llvm@12/include -DFFI_BUILDING=1 -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c c/_cffi_backend.c -o build/temp.macosx-10.14-arm64-3.8/c/_cffi_backend.o -iwithsysroot/usr/include/ffi
    clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -Wl,-headerpad,0x1000 -L/opt/homebrew/opt/llvm@12/lib -I/opt/homebrew/opt/llvm@12/include build/temp.macosx-10.14-arm64-3.8/c/_cffi_backend.o -lffi -o build/lib.macosx-10.14-arm64-3.8/_cffi_backend.cpython-38-darwin.so
    ld: warning: dylib (/opt/homebrew/opt/llvm@12/lib/libunwind.dylib) was built for newer macOS version (12.0) than being linked (11.0)
    ld: warning: dylib (/opt/homebrew/opt/llvm@12/lib/libunwind.dylib) was built for newer macOS version (12.0) than being linked (11.0)
    ld: in '/opt/homebrew/opt/llvm@12/lib/libunwind.dylib', building for macOS-x86_64 but attempting to link with file built for macOS-arm64
    clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'clang' failed with exit status 1
    ----------------------------------------
    ERROR: Failed building wheel for cffi
    Running setup.py clean for cffi
  Failed to build cffi
  Installing collected packages: setuptools, wheel, pycparser, cffi, semantic-version, typing-extensions, setuptools-rust
      Running setup.py install for cffi: started
      Running setup.py install for cffi: finished with status 'error'
      ERROR: Command errored out with exit status 1:

2. mac version

my mac version is: macOS Monterey 12.5.1 with M1 Pro chip

Peefy commented 1 year ago

I try the same command on my m1 mac, it works well. The error appears to occur on llvm12 and clang-12. Can you try to use the clang default path /usr/bin/clang that comes with your computer? Just rename /opt/homebrew/opt/llvm@12/bin/clang to other names, such as /opt/homebrew/opt/llvm@12/bin/clang-bak.

amyXia1994 commented 1 year ago

I try the same command on my m1 mac, it works well. The error appears to occur on llvm12 and clang-12. Can you try to use the clang default path /usr/bin/clang that comes with your computer? Just rename /opt/homebrew/opt/llvm@12/bin/clang to other names, such as /opt/homebrew/opt/llvm@12/bin/clang-bak.

I moved the clang installed by brew, and now which clang points to /usr/bin/clang And I tried again the same error still occours.

Peefy commented 1 year ago

@amyXia1994. The way I can think of to walk around is brew install llvm@14, I will try to remove the cffi dependency later.

amyXia1994 commented 1 year ago

@amyXia1994. The way I can think of to walk around is brew install llvm@14, I will try to remove the cffi dependency later.

Thanks, worked for me. I've done brew uninstall llvm@12 and brew install llvm@14, and I tried python3 -m pip install kclvm && python3 -m kclvm --help again, all things go well