OkGoDoIt / frame-sdk-python

The Python SDK for the Frame from @brilliantlabsAR
MIT License
12 stars 4 forks source link

simpleaudio dependency breaks build with docker #2

Open viac92 opened 2 months ago

viac92 commented 2 months ago

Hi!

I'm trying to run a container with the SDK installed on but every time I tried to achieve this I get this error:

Running setup.py install for simpleaudio: finished with status 'error'
error: subprocess-exited-with-error

× Running setup.py install for simpleaudio did not run successfully.
│ exit code: 1
   ╰─> [21 lines of output]
       running install
       running build
       running build_py
       creating build
       creating build/lib.linux-x86_64-3.9
       creating build/lib.linux-x86_64-3.9/simpleaudio
       copying simpleaudio/__init__.py -> build/lib.linux-x86_64-3.9/simpleaudio
       copying simpleaudio/shiny.py -> build/lib.linux-x86_64-3.9/simpleaudio
       copying simpleaudio/functionchecks.py -> build/lib.linux-x86_64-3.9/simpleaudio
       creating build/lib.linux-x86_64-3.9/simpleaudio/test_audio
       copying simpleaudio/test_audio/c.wav -> build/lib.linux-x86_64-3.9/simpleaudio/test_audio
       copying simpleaudio/test_audio/e.wav -> build/lib.linux-x86_64-3.9/simpleaudio/test_audio
       copying simpleaudio/test_audio/g.wav -> build/lib.linux-x86_64-3.9/simpleaudio/test_audio
       copying simpleaudio/test_audio/left_right.wav -> build/lib.linux-x86_64-3.9/simpleaudio/test_audio
       copying simpleaudio/test_audio/notes_2_16_44.wav -> build/lib.linux-x86_64-3.9/simpleaudio/test_audio
       running build_ext
       building 'simpleaudio._simpleaudio' extension
       creating build/temp.linux-x86_64-3.9
       creating build/temp.linux-x86_64-3.9/c_src
       gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DDEBUG=0 -I/usr/local/include/python3.9 -c c_src/posix_mutex.c -o build/temp.linux-x86_64-3.9/c_src/posix_mutex.o
       error: command 'gcc' failed: No such file or directory
       [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.
 ╰─> simpleaudio

This is my Dockerfile:

FROM python:3.9-slim

WORKDIR /app

# Copy the requirements file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8765

CMD ["python", "server-script.py"]

I also see that is a common issue for this package: https://github.com/hamiltron/py-simple-audio/issues/75 https://github.com/hamiltron/py-simple-audio/issues/70 https://github.com/hamiltron/py-simple-audio/issues/62

maybe we should use a more stable and supported package for audio.

In the mean time any suggestions about this error?

Thank you!

viac92 commented 2 months ago

I managed to compile the docker image adding gcc and portaudio for compatibility with simpleaudio.

So my Dockerfile is:

FROM python:3.9-slim

# Installa le dipendenze necessarie
RUN apt-get update && apt-get install -y \
    gcc \
    portaudio19-dev

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD ["python", "server-script.py"]
OkGoDoIt commented 4 weeks ago

I used simpleaudio because I thought it would be a simple, low dependency, low hassle solution. Looks like I was wrong. Technically you don’t need simpleaudio unless you’re going to be playing back the audio received from the Frame. It’s only used by the helper function that plays audio.

Does anyone with more Python audio experience have a recommendation for a different package?

userElaina commented 3 hours ago

Does anyone with more Python audio experience have a recommendation for a different package?

hi, how about playsound and pyaudio?