Fangjun Kuang
Committed by GitHub

fix building linux x86 wheels (#484)

@@ -38,6 +38,15 @@ jobs: @@ -38,6 +38,15 @@ jobs:
38 - name: Build wheels 38 - name: Build wheels
39 uses: pypa/cibuildwheel@v2.15.0 39 uses: pypa/cibuildwheel@v2.15.0
40 env: 40 env:
  41 + CIBW_BEFORE_ALL: |
  42 + git clone --depth 1 https://github.com/alsa-project/alsa-lib
  43 + cd alsa-lib
  44 + ./gitcompile
  45 + cd ..
  46 + echo "PWD"
  47 + ls -lh /project/alsa-lib/src/.libs
  48 +
  49 + CIBW_ENVIRONMENT: CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH SHERPA_ONNX_ALSA_LIB_DIR=/project/alsa-lib/src/.libs LD_LIBRARY_PATH=/project/build/bdist.linux-x86_64/wheel/sherpa_onnx/lib:$SHERPA_ONNX_ALSA_LIB_DIR SHERPA_ONNX_MAKE_ARGS="VERBOSE=1"
41 CIBW_BUILD: "${{ matrix.python-version}}-* " 50 CIBW_BUILD: "${{ matrix.python-version}}-* "
42 CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686" 51 CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686"
43 CIBW_BUILD_VERBOSITY: 3 52 CIBW_BUILD_VERBOSITY: 3
@@ -33,10 +33,19 @@ jobs: @@ -33,10 +33,19 @@ jobs:
33 - name: Build wheels 33 - name: Build wheels
34 uses: pypa/cibuildwheel@v2.15.0 34 uses: pypa/cibuildwheel@v2.15.0
35 env: 35 env:
  36 + CIBW_BEFORE_ALL: |
  37 + git clone --depth 1 https://github.com/alsa-project/alsa-lib
  38 + cd alsa-lib
  39 + ./gitcompile
  40 + cd ..
  41 + echo "PWD"
  42 + ls -lh /project/alsa-lib/src/.libs
  43 +
  44 + CIBW_ENVIRONMENT: CPLUS_INCLUDE_PATH=/project/alsa-lib/include:$CPLUS_INCLUDE_PATH SHERPA_ONNX_ALSA_LIB_DIR=/project/alsa-lib/src/.libs LD_LIBRARY_PATH=/project/build/bdist.linux-x86_64/wheel/sherpa_onnx/lib:$SHERPA_ONNX_ALSA_LIB_DIR SHERPA_ONNX_MAKE_ARGS="VERBOSE=1"
  45 +
36 CIBW_BUILD: "${{ matrix.python-version}}-* " 46 CIBW_BUILD: "${{ matrix.python-version}}-* "
37 CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686" 47 CIBW_SKIP: "cp27-* cp35-* cp36-* *-win32 pp* *-musllinux* *-manylinux_i686"
38 CIBW_BUILD_VERBOSITY: 3 48 CIBW_BUILD_VERBOSITY: 3
39 - CIBW_ENVIRONMENT_LINUX: LD_LIBRARY_PATH='/project/build/bdist.linux-x86_64/wheel/sherpa_onnx/lib'  
40 49
41 - name: Display wheels 50 - name: Display wheels
42 shell: bash 51 shell: bash
@@ -26,6 +26,18 @@ def is_windows(): @@ -26,6 +26,18 @@ def is_windows():
26 return platform.system() == "Windows" 26 return platform.system() == "Windows"
27 27
28 28
  29 +def is_linux():
  30 + return platform.system() == "Linux"
  31 +
  32 +
  33 +def is_arm64():
  34 + return platform.machine() in ["arm64", "aarch64"]
  35 +
  36 +
  37 +def is_x86():
  38 + return platform.machine() in ["i386", "i686", "x86_64"]
  39 +
  40 +
29 try: 41 try:
30 from wheel.bdist_wheel import bdist_wheel as _bdist_wheel 42 from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
31 43
@@ -144,8 +156,10 @@ class BuildExtension(build_ext): @@ -144,8 +156,10 @@ class BuildExtension(build_ext):
144 binaries += ["sherpa-onnx-vad-microphone-offline-asr"] 156 binaries += ["sherpa-onnx-vad-microphone-offline-asr"]
145 binaries += ["sherpa-onnx-offline-tts"] 157 binaries += ["sherpa-onnx-offline-tts"]
146 binaries += ["sherpa-onnx-offline-tts-play"] 158 binaries += ["sherpa-onnx-offline-tts-play"]
147 - binaries += ["sherpa-onnx-alsa"]  
148 - binaries += ["sherpa-onnx-offline-tts-play-alsa"] 159 +
  160 + if is_linux() and (is_arm64() or is_x86()):
  161 + binaries += ["sherpa-onnx-alsa"]
  162 + binaries += ["sherpa-onnx-offline-tts-play-alsa"]
149 163
150 if is_windows(): 164 if is_windows():
151 binaries += ["kaldi-native-fbank-core.dll"] 165 binaries += ["kaldi-native-fbank-core.dll"]
@@ -168,10 +182,6 @@ class BuildExtension(build_ext): @@ -168,10 +182,6 @@ class BuildExtension(build_ext):
168 if not src_file.is_file(): 182 if not src_file.is_file():
169 src_file = install_dir / ".." / (f + suffix) 183 src_file = install_dir / ".." / (f + suffix)
170 184
171 - if not src_file.is_file() and 'alsa' in f:  
172 - print(f'Skipping {f}')  
173 - continue  
174 -  
175 print(f"Copying {src_file} to {out_bin_dir}/") 185 print(f"Copying {src_file} to {out_bin_dir}/")
176 shutil.copy(f"{src_file}", f"{out_bin_dir}/") 186 shutil.copy(f"{src_file}", f"{out_bin_dir}/")
177 187
@@ -12,6 +12,9 @@ from cmake.cmake_extension import ( @@ -12,6 +12,9 @@ from cmake.cmake_extension import (
12 bdist_wheel, 12 bdist_wheel,
13 cmake_extension, 13 cmake_extension,
14 is_windows, 14 is_windows,
  15 + is_linux,
  16 + is_arm64,
  17 + is_x86,
15 ) 18 )
16 19
17 20
@@ -60,8 +63,11 @@ def get_binaries_to_install(): @@ -60,8 +63,11 @@ def get_binaries_to_install():
60 binaries += ["sherpa-onnx-vad-microphone-offline-asr"] 63 binaries += ["sherpa-onnx-vad-microphone-offline-asr"]
61 binaries += ["sherpa-onnx-offline-tts"] 64 binaries += ["sherpa-onnx-offline-tts"]
62 binaries += ["sherpa-onnx-offline-tts-play"] 65 binaries += ["sherpa-onnx-offline-tts-play"]
63 - binaries += ["sherpa-onnx-alsa"]  
64 - binaries += ["sherpa-onnx-offline-tts-play-alsa"] 66 +
  67 + if is_linux() and (is_arm64() or is_x86()):
  68 + binaries += ["sherpa-onnx-alsa"]
  69 + binaries += ["sherpa-onnx-offline-tts-play-alsa"]
  70 +
65 if is_windows(): 71 if is_windows():
66 binaries += ["kaldi-native-fbank-core.dll"] 72 binaries += ["kaldi-native-fbank-core.dll"]
67 binaries += ["sherpa-onnx-c-api.dll"] 73 binaries += ["sherpa-onnx-c-api.dll"]