0

I'm trying to build a speech recognition application that works in a browser. Currently using pyodide with a web worker. I have my own package, built alongside pyaudio, that I use for the web worker.

Is there a way that I can include a brew instillation, specifically portaudio, inside of my python package so that when I build the package, portaudio is included in the wheel file? I need portaudio included for this to work in the browser.

Thank you!

Luke
  • 3
  • 1
  • You would need to build portaudio for WebAssembly, and according to https://github.com/PortAudio/portaudio/issues/497#issuecomment-777149792 that would require additional development to support audio API available WASM – rth Mar 23 '22 at 18:11

1 Answers1

1

I'm understanding two different questions here, so I'll try to answer them both.

Can I have a python build fetch a Homebrew project during buildtime

To my knowledge, the answer is no. The Python distribution system is separate from Homebrew, and they can't interact in this fashion.

Even if they could, this wouldn't necessarily be desirable:

  • What happens if the user isn't on macOS (or Linux)? Then the build would fail.
  • The prefix that Homebrew will install the package in isn't very deterministic. The user might be using a custom prefix, or they might be on Apple Silicon (which has a different default prefix to Intel).
    • Your python package might run into some difficulty locating the package.
  • What about if they don't have Homebrew installed? They might have another package manager like MacPorts or Fink, or maybe none at all.

Can I bundle portaudio into the build distribution?

Maybe? Even if you could, I almost certainly wouldn't recommend it.

  • Bundling dependencies increases the size of the distribution unnecessarily.
  • It would take a reasonable amount of effort to setup, assuming you can do it.

All these reasons are why for the majority of projects that have a similar setup, you will find that they recommend installing certain packages with their system package manager first, before building the Python source code.

This allows them to choose whatever package manager they have installed, and it should also be a quick and painless process.

Therefore, just change your installation instructions to the following:

# On macOS
brew install portaudio
pip install ...
Haren S
  • 719
  • 4
  • 15