pynini: (Yet Another) 'fst/util.h' file not found

Environment

  • OS: macOS Sequoia 15.2
  • Python Version: 3.12
  • OpenFST Version: 1.8.3
  • Pynini Version: 2.1.6-post1

Description of Issue

Pynini fails to build, cf. below.

.venv/bin/pip install pynini                                                                   
Collecting pynini
  Downloading pynini-2.1.6.post1.tar.gz (790 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 790.4/790.4 kB 5.9 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pynini
  Building wheel for pynini (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for pynini (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [68 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.macosx-15.0-arm64-cpython-312/pywrapfst
      copying pywrapfst/__init__.py -> build/lib.macosx-15.0-arm64-cpython-312/pywrapfst
      creating build/lib.macosx-15.0-arm64-cpython-312/pynini
      copying pynini/__init__.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini
      creating build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/chatspeak.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/chatspeak_model.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/weather.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/__init__.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/numbers.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/plurals.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/t9.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/case.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/dates.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/g2p.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      creating build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/edit_transducer.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/utf8.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/__init__.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/features.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/pynutil.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/paradigms.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/tagger.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/stringfile.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/rule_cascade.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/rewrite.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/byte.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      creating build/lib.macosx-15.0-arm64-cpython-312/pynini/export
      copying pynini/export/__init__.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/export
      copying pynini/export/export.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/export
      copying pynini/export/multi_grm_example.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/export
      copying pynini/export/multi_grm.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/export
      copying pynini/export/grm.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/export
      copying pynini/export/grm_example.py -> build/lib.macosx-15.0-arm64-cpython-312/pynini/export
      running egg_info
      writing pynini.egg-info/PKG-INFO
      writing dependency_links to pynini.egg-info/dependency_links.txt
      writing top-level names to pynini.egg-info/top_level.txt
      reading manifest file 'pynini.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE'
      adding license file 'AUTHORS'
      writing manifest file 'pynini.egg-info/SOURCES.txt'
      copying pywrapfst/BUILD.bazel -> build/lib.macosx-15.0-arm64-cpython-312/pywrapfst
      copying pywrapfst/__init__.pyi -> build/lib.macosx-15.0-arm64-cpython-312/pywrapfst
      copying pywrapfst/py.typed -> build/lib.macosx-15.0-arm64-cpython-312/pywrapfst
      copying pynini/BUILD.bazel -> build/lib.macosx-15.0-arm64-cpython-312/pynini
      copying pynini/__init__.pyi -> build/lib.macosx-15.0-arm64-cpython-312/pynini
      copying pynini/py.typed -> build/lib.macosx-15.0-arm64-cpython-312/pynini
      copying pynini/examples/BUILD.bazel -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/examples/py.typed -> build/lib.macosx-15.0-arm64-cpython-312/pynini/examples
      copying pynini/lib/BUILD.bazel -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/lib/py.typed -> build/lib.macosx-15.0-arm64-cpython-312/pynini/lib
      copying pynini/export/BUILD.bazel -> build/lib.macosx-15.0-arm64-cpython-312/pynini/export
      copying pynini/export/grm_py_build_defs.bzl -> build/lib.macosx-15.0-arm64-cpython-312/pynini/export
      copying pynini/export/py.typed -> build/lib.macosx-15.0-arm64-cpython-312/pynini/export
      running build_ext
      building '_pywrapfst' extension
      creating build/temp.macosx-15.0-arm64-cpython-312/extensions
      clang++ -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -I/Users/eslksw/GitLab/aemorph/.venv/include -I/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c extensions/_pywrapfst.cpp -o build/temp.macosx-15.0-arm64-cpython-312/extensions/_pywrapfst.o -std=c++17 -Wno-register -Wno-deprecated-declarations -Wno-unused-function -Wno-unused-local-typedefs -funsigned-char -stdlib=libc++ -mmacosx-version-min=10.12
      extensions/_pywrapfst.cpp:1291:10: fatal error: 'fst/util.h' file not found
       1291 | #include <fst/util.h>
            |          ^~~~~~~~~~~~
      1 error generated.
      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 pynini
Failed to build pynini
ERROR: Could not build wheels for pynini, which is required to install pyproject.toml-based projects

Comment

So, I have been struggling to install Pynini, like many others before me, because of the 'fst/util.h' file not found error. I started out with OpenFST 1.8.4, then I saw it’s not officially supported, so I built OpenFST 1.8.3 instead. Still, the same error. I kinda gave up and tried learning Thrax instead, but the documentation is very meagre, and I need to define APIs to communicate with the rest of my stack. So, I came on here to ask about the error once more. I have read through all relevant issue threads and it’s none of the problems in there, so I am kinda lost.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

Hi, I encountered this issue and solved it by the following:

  1. brew install openfst
  2. Since it’s openfst v1.8.4, I have to edit extensions/stringmap.h on lines 185 and 230 to replace fst::StringJoin with fst::StrJoin because the build will throw an error if I don’t.
  3. CFLAGS="-I/opt/homebrew/Cellar/openfst/1.8.4/include" LDFLAGS="-L/opt/homebrew/Cellar/openfst/1.8.4/lib" python setup.py bdist_wheel
    pip install dist/pynini-2.1.6.post1-cp310-cp310-macosx_15_0_arm64.whl
    

note: I also noticed that my clang is homebrew’s clang:

$ which clang
/opt/homebrew/opt/llvm/bin/clang
$ which clang++
/opt/homebrew/opt/llvm/bin/clang++

Hmm, yes, it works with the clang provided by Xcode.

❯ /usr/bin/clang --version
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

set -x CC /usr/bin/clang
set -x CXX /usr/bin/clang++
set -x C_INCLUDE_PATH /opt/homebrew/opt/openfst@1.8.3/include
set -x CPLUS_INCLUDE_PATH /opt/homebrew/opt/openfst@1.8.3/include
set -x LIBRARY_PATH /opt/homebrew/opt/openfst@1.8.3/lib
set -x LD_LIBRARY_PATH /opt/homebrew/opt/openfst@1.8.3/lib

pip install pynini==2.1.6

You’re welcome to try; we can accept PRs that add that ability if you’re willing to sign a CLA.

We do distribute a static linked version with manylinux but that’s x86_64 only and is an enormous effort to keep up to date. There’s no equivalent for any other platform that I know of.