readbeyond / aeneas

aeneas is a Python/C library and a set of tools to automagically synchronize audio and text (aka forced alignment)
http://www.readbeyond.it/aeneas/
GNU Affero General Public License v3.0
2.53k stars 233 forks source link

macOS dependency install #305

Open itsjamie opened 1 year ago

itsjamie commented 1 year ago

OS/arch: macOS 13.5.2 / arm64

Install command: pip wheel --use-pep517 "aeneas (==1.7.3.0)"

I have a build where aeneas is used as a dependency for a project, and my system does have espeak installed via homebrew as recommended in the setup warning that is printed. It failed to install via the tooling in my project (Poetry) and gave the command above as a method of testing it outside of any of its own tooling as a method of testing.

Looking at the output log. The library is not found. I believe this is because the clang command does not contain the -L/opt/homebrew/lib, indicating that it should look in that path for libraries.

I'm going to attempt just modifying my ld path and try again, but given you advise users to install via homebrew, do you think adding it makes sense?

clang -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk build/temp.macosx-13-arm64-cpython-311/aeneas/cew/cew_func.o build/temp.macosx-13-arm64-cpython-311/aeneas/cew/cew_py.o -lespeak -o build/lib.macosx-13-arm64-cpython-311/aeneas/cew/cew.cpython-311-darwin.so
      ld: library not found for -lespeak
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      error: Command "clang -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk build/temp.macosx-13-arm64-cpython-311/aeneas/cew/cew_func.o build/temp.macosx-13-arm64-cpython-311/aeneas/cew/cew_py.o -lespeak -o build/lib.macosx-13-arm64-cpython-311/aeneas/cew/cew.cpython-311-darwin.so" failed with exit status 1
itsjamie commented 1 year ago

Setting LIBRARY_PATH=/opt/homebrew/lib pip wheel --use-pep517 "aeneas (==1.7.3.0)" worked to compile in my scenario.

It looks like it would have worked on Intel Macs as the default install directory for Homebrew was /usr/local/lib which is in the default lookup path.

On the M1 mac, the default install directory is now /opt/homebrew/lib, which is notably, not in the default search path.

So, for the build to work automatically on the M1 variant, with the current instructions you would need to add -L/opt/homebrew/lib if the expectation is that espeak is installed via homebrew prior.

ezekiel747 commented 6 months ago

So, for the build to work automatically on the M1 variant, with the current instructions you would need to add -L/opt/homebrew/lib if the expectation is that espeak is installed via homebrew prior.

Could you please be more specific: where exactly should this option be used: -L/opt/homebrew/lib ?

pimgeek commented 6 months ago

After an hour's trial-and-error, I finally know how to tell pip how to find espeak library, using the following command:

AENEAS_WITH_CEW=True; LIBRARY_PATH=/opt/homebrew/lib pip install aeneas

and the diagnosis shows that cew is enabled

$ python -m aeneas.diagnostics

[INFO] ffprobe        OK
[INFO] ffmpeg         OK
[INFO] espeak         OK
[INFO] aeneas.tools   OK
[WARN] shell encoding WARNING
[WARN]   The default input encoding of your shell is not UTF-8
[WARN]   The default output encoding of your shell is not UTF-8
[INFO]   If you plan to use aeneas on the command line,
[INFO]   you might want to 'export PYTHONIOENCODING=UTF-8' in your shell
[INFO] aeneas.cdtw    AVAILABLE
[INFO] aeneas.cmfcc   AVAILABLE
[INFO] aeneas.cew     AVAILABLE
[INFO] All required dependencies are met and all available Python C extensions are working

Could you please be more specific: where exactly should this option be used: -L/opt/homebrew/lib ?

TanishSurana commented 6 months ago

After an hour's trial-and-error, I finally know how to tell pip how to find espeak library, using the following command:

AENEAS_WITH_CEW=True; LIBRARY_PATH=/opt/homebrew/lib pip install aeneas

and the diagnosis shows that cew is enabled

$ python -m aeneas.diagnostics

[INFO] ffprobe        OK
[INFO] ffmpeg         OK
[INFO] espeak         OK
[INFO] aeneas.tools   OK
[WARN] shell encoding WARNING
[WARN]   The default input encoding of your shell is not UTF-8
[WARN]   The default output encoding of your shell is not UTF-8
[INFO]   If you plan to use aeneas on the command line,
[INFO]   you might want to 'export PYTHONIOENCODING=UTF-8' in your shell
[INFO] aeneas.cdtw    AVAILABLE
[INFO] aeneas.cmfcc   AVAILABLE
[INFO] aeneas.cew     AVAILABLE
[INFO] All required dependencies are met and all available Python C extensions are working

Could you please be more specific: where exactly should this option be used: -L/opt/homebrew/lib ?

WORKED, thank you our lord and saviour.