iamDecode / sklearn-pmml-model

A library to parse and convert PMML models into Scikit-learn estimators.
BSD 2-Clause "Simplified" License
76 stars 15 forks source link

Fix building on apple silicon macs #42

Closed iamDecode closed 2 years ago

iamDecode commented 2 years ago

As reported in #41, building on Apple Silicon Macs caused issues like

ERROR: Command errored out with exit status 1:
     command: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/0z/cx87zyvn7ssfpp4fc7bff4rw0000gn/T/pip-install-xr993ftf/miniaudio_41126c03fa9b4343962ac371bf368fd5/setup.py'"'"'; __file__='"'"'/private/var/folders/0z/cx87zyvn7ssfpp4fc7bff4rw0000gn/T/pip-install-xr993ftf/miniaudio_41126c03fa9b4343962ac371bf368fd5/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/0z/cx87zyvn7ssfpp4fc7bff4rw0000gn/T/pip-record-ox8ldrmt/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/harry/Library/Python/3.8/include/python3.8/miniaudio
         cwd: /private/var/folders/0z/cx87zyvn7ssfpp4fc7bff4rw0000gn/T/pip-install-xr993ftf/miniaudio_41126c03fa9b4343962ac371bf368fd5/
    Complete output (15 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14.6-arm64-3.8
    copying miniaudio.py -> build/lib.macosx-10.14.6-arm64-3.8
    running build_ext
    generating cffi module 'build/temp.macosx-10.14.6-arm64-3.8/_miniaudio.c'
    creating build/temp.macosx-10.14.6-arm64-3.8
    building '_miniaudio' extension
    creating build/temp.macosx-10.14.6-arm64-3.8/build
    creating build/temp.macosx-10.14.6-arm64-3.8/build/temp.macosx-10.14.6-arm64-3.8
    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 -DMA_NO_GENERATION=1 -I/private/var/folders/0z/cx87zyvn7ssfpp4fc7bff4rw0000gn/T/pip-install-xr993ftf/miniaudio_41126c03fa9b4343962ac371bf368fd5 -I/private/var/folders/0z/cx87zyvn7ssfpp4fc7bff4rw0000gn/T/pip-install-xr993ftf/miniaudio_41126c03fa9b4343962ac371bf368fd5 -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c build/temp.macosx-10.14.6-arm64-3.8/_miniaudio.c -o build/temp.macosx-10.14.6-arm64-3.8/build/temp.macosx-10.14.6-arm64-3.8/_miniaudio.o -g1 -O3 -ffast-math -mtune=native -march=native
    clang: error: the clang compiler does not support '-march=native'
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/0z/cx87zyvn7ssfpp4fc7bff4rw0000gn/T/pip-install-xr993ftf/miniaudio_41126c03fa9b4343962ac371bf368fd5/setup.py'"'"'; __file__='"'"'/private/var/folders/0z/cx87zyvn7ssfpp4fc7bff4rw0000gn/T/pip-install-xr993ftf/miniaudio_41126c03fa9b4343962ac371bf368fd5/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/0z/cx87zyvn7ssfpp4fc7bff4rw0000gn/T/pip-record-ox8ldrmt/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/harry/Library/Python/3.8/include/python3.8/miniaudio Check the logs for full command output.

As a fix, the -march=native argument (along with other incompatible flags) is dropped specifically for M1 builds. In addition, this PR adds apple silicon wheel building on CI to ensure the build works.