cheofusi / just_playback

A small library for playing audio files in python, with essential playback functionality.
MIT License
70 stars 7 forks source link

PIP install fails on macOS 12.2.1 with Apple M1 chip #13

Closed tomhaines closed 2 years ago

tomhaines commented 2 years ago

Python: Python 3.9.9 PIP: 22.0.4

PIP install fails with the following error:

pip3 install just_playback
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Collecting just_playback
  Using cached just_playback-0.1.6.tar.gz (504 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: cffi>=1.0.0 in /opt/homebrew/lib/python3.9/site-packages (from just_playback) (1.15.0)
Requirement already satisfied: tinytag in /opt/homebrew/lib/python3.9/site-packages (from just_playback) (1.8.0)
Requirement already satisfied: pycparser in /opt/homebrew/lib/python3.9/site-packages (from cffi>=1.0.0->just_playback) (2.21)
Building wheels for collected packages: just_playback
  Building wheel for just_playback (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [22 lines of output]
      /opt/homebrew/lib/python3.9/site-packages/setuptools/__init__.py:148: SetuptoolsDeprecationWarning: setup_requires is deprecated. Supply build dependencies using PEP 517 pyproject.toml build-requires.
        warnings.warn(
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-12-arm64-3.9
      creating build/lib.macosx-12-arm64-3.9/just_playback
      copying just_playback/playback.py -> build/lib.macosx-12-arm64-3.9/just_playback
      copying just_playback/ma_result.py -> build/lib.macosx-12-arm64-3.9/just_playback
      copying just_playback/__init__.py -> build/lib.macosx-12-arm64-3.9/just_playback
      running build_ext
      generating cffi module 'build/temp.macosx-12-arm64-3.9/_ma_playback.c'
      creating build/temp.macosx-12-arm64-3.9
      building '_ma_playback' extension
      creating build/temp.macosx-12-arm64-3.9/build
      creating build/temp.macosx-12-arm64-3.9/build/temp.macosx-12-arm64-3.9
      creating build/temp.macosx-12-arm64-3.9/just_playback
      creating build/temp.macosx-12-arm64-3.9/just_playback/miniaudio
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -DMA_NO_GENERATION=1 -Ijust_playback -I/opt/homebrew/include -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/temp.macosx-12-arm64-3.9/_ma_playback.c -o build/temp.macosx-12-arm64-3.9/build/temp.macosx-12-arm64-3.9/_ma_playback.o -g1 -O3 -ffast-math -mtune=native -march=native
      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: Failed building wheel for just_playback
  Running setup.py clean for just_playback
Failed to build just_playback
Installing collected packages: just_playback
  DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
  Running setup.py install for just_playback ... error
  error: subprocess-exited-with-error

  × Running setup.py install for just_playback did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      /opt/homebrew/lib/python3.9/site-packages/setuptools/__init__.py:148: SetuptoolsDeprecationWarning: setup_requires is deprecated. Supply build dependencies using PEP 517 pyproject.toml build-requires.
        warnings.warn(
      running install
      /opt/homebrew/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.macosx-12-arm64-3.9
      creating build/lib.macosx-12-arm64-3.9/just_playback
      copying just_playback/playback.py -> build/lib.macosx-12-arm64-3.9/just_playback
      copying just_playback/ma_result.py -> build/lib.macosx-12-arm64-3.9/just_playback
      copying just_playback/__init__.py -> build/lib.macosx-12-arm64-3.9/just_playback
      running build_ext
      generating cffi module 'build/temp.macosx-12-arm64-3.9/_ma_playback.c'
      creating build/temp.macosx-12-arm64-3.9
      building '_ma_playback' extension
      creating build/temp.macosx-12-arm64-3.9/build
      creating build/temp.macosx-12-arm64-3.9/build/temp.macosx-12-arm64-3.9
      creating build/temp.macosx-12-arm64-3.9/just_playback
      creating build/temp.macosx-12-arm64-3.9/just_playback/miniaudio
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -DMA_NO_GENERATION=1 -Ijust_playback -I/opt/homebrew/include -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/temp.macosx-12-arm64-3.9/_ma_playback.c -o build/temp.macosx-12-arm64-3.9/build/temp.macosx-12-arm64-3.9/_ma_playback.o -g1 -O3 -ffast-math -mtune=native -march=native
      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: legacy-install-failure

× Encountered error while trying to install package.
╰─> just_playback

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
cheofusi commented 2 years ago

Hi Tom,

Thanks for reporting this. It appears that clang doesn't support -march=native for the M1. The next release will take this into account but for now you could

  1. download an extract the source files
  2. remove the last element of the compiler_args list at line 20 of build_ffi_module.py
  3. recreate a new artifact with tar -czvf just_playback-0.1.6.tar.gz just_playback-0.1.6/ (make sure to first delete the compressed file you downloaded)
  4. install with pip install just_playback-0.1.6.tar.gz
tomhaines commented 2 years ago

Thank you. I was able to install using this method.

mastanbol commented 2 years ago

If you are using Mac M1 then try the below thing.

export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
  export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1