jina-ai / annlite

⚡ A fast embedded library for approximate nearest neighbor search
Apache License 2.0
216 stars 22 forks source link

Support for Mac with Apple Silicon #187

Closed ZiniuYu closed 2 years ago

ZiniuYu commented 2 years ago

I get the following error messages when installing on Mac with M1:

$ pip3 install -e .
... (downloading and requirements checking omitted)
Installing collected packages: annlite
  Running setup.py develop for annlite
    error: subprocess-exited-with-error

    × python setup.py develop did not run successfully.
    │ exit code: 1
    ╰─> [20 lines of output]
        Error in sitecustomize; set PYTHONVERBOSE for traceback:
        AssertionError:
        running develop
        running egg_info
        writing annlite.egg-info/PKG-INFO
        writing dependency_links to annlite.egg-info/dependency_links.txt
        writing requirements to annlite.egg-info/requires.txt
        writing top-level names to annlite.egg-info/top_level.txt
        reading manifest file 'annlite.egg-info/SOURCES.txt'
        reading manifest template 'MANIFEST.in'
        adding license file 'LICENSE'
        writing manifest file 'annlite.egg-info/SOURCES.txt'
        running build_ext
        clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/8m/b8y6xg410sz19rwf9v_6fqch0000gn/T/tmpp9jow8ev.cpp -o var/folders/8m/b8y6xg410sz19rwf9v_6fqch0000gn/T/tmpp9jow8ev.o -std=c++14
        building 'annlite.hnsw_bind' extension
        creating build/temp.macosx-12-arm64-3.10
        creating build/temp.macosx-12-arm64-3.10/bindings
        clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pybind11/include -I/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/include -I./include/hnswlib -I/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c ./bindings/hnsw_bindings.cpp -o build/temp.macosx-12-arm64-3.10/./bindings/hnsw_bindings.o -O3 -march=native -stdlib=libc++ -mmacosx-version-min=10.7 -DVERSION_INFO="0.3.14" -std=c++14
        clang: error: the clang compiler does not support '-march=native'
        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: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
    Error in sitecustomize; set PYTHONVERBOSE for traceback:
    AssertionError:
    running develop
    running egg_info
    writing annlite.egg-info/PKG-INFO
    writing dependency_links to annlite.egg-info/dependency_links.txt
    writing requirements to annlite.egg-info/requires.txt
    writing top-level names to annlite.egg-info/top_level.txt
    reading manifest file 'annlite.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    adding license file 'LICENSE'
    writing manifest file 'annlite.egg-info/SOURCES.txt'
    running build_ext
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/8m/b8y6xg410sz19rwf9v_6fqch0000gn/T/tmpp9jow8ev.cpp -o var/folders/8m/b8y6xg410sz19rwf9v_6fqch0000gn/T/tmpp9jow8ev.o -std=c++14
    building 'annlite.hnsw_bind' extension
    creating build/temp.macosx-12-arm64-3.10
    creating build/temp.macosx-12-arm64-3.10/bindings
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pybind11/include -I/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/include -I./include/hnswlib -I/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c ./bindings/hnsw_bindings.cpp -o build/temp.macosx-12-arm64-3.10/./bindings/hnsw_bindings.o -O3 -march=native -stdlib=libc++ -mmacosx-version-min=10.7 -DVERSION_INFO="0.3.14" -std=c++14
    clang: error: the clang compiler does not support '-march=native'
    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.
numb3r3 commented 2 years ago

@ZiniuYu Could you try the trick from https://github.com/nmslib/nmslib/blob/master/python_bindings/setup.py#L132-L142