Fangjun Kuang
Committed by GitHub

Fix building wheels for macOS (#2192)

@@ -20,7 +20,7 @@ jobs: @@ -20,7 +20,7 @@ jobs:
20 strategy: 20 strategy:
21 fail-fast: false 21 fail-fast: false
22 matrix: 22 matrix:
23 - os: [macos-latest] 23 + os: [macos-13]
24 python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"] 24 python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"]
25 25
26 steps: 26 steps:
@@ -88,7 +88,13 @@ jobs: @@ -88,7 +88,13 @@ jobs:
88 TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 88 TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
89 TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 89 TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
90 run: | 90 run: |
91 - python3 -m pip install --break-system-packages --upgrade pip  
92 - python3 -m pip install --break-system-packages wheel twine==5.0.0 setuptools 91 + opts='--break-system-packages'
  92 + v=${{ matrix.python-version }}
  93 + if [[ $v == cp38 || $v == cp39 ]]; then
  94 + opts=''
  95 + fi
  96 +
  97 + python3 -m pip install $opts --upgrade pip
  98 + python3 -m pip install $opts wheel twine==5.0.0 setuptools
93 99
94 twine upload ./wheelhouse/*.whl 100 twine upload ./wheelhouse/*.whl
@@ -35,7 +35,7 @@ std::vector<char> ReadFile(AAssetManager *mgr, const std::string &filename) { @@ -35,7 +35,7 @@ std::vector<char> ReadFile(AAssetManager *mgr, const std::string &filename) {
35 AAsset *asset = AAssetManager_open(mgr, filename.c_str(), AASSET_MODE_BUFFER); 35 AAsset *asset = AAssetManager_open(mgr, filename.c_str(), AASSET_MODE_BUFFER);
36 if (!asset) { 36 if (!asset) {
37 __android_log_print(ANDROID_LOG_FATAL, "sherpa-onnx", 37 __android_log_print(ANDROID_LOG_FATAL, "sherpa-onnx",
38 - "Read binary file: Load %s failed", filename.c_str()); 38 + "Read binary file: Load '%s' failed", filename.c_str());
39 exit(-1); 39 exit(-1);
40 } 40 }
41 41
@@ -123,9 +123,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl { @@ -123,9 +123,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl {
123 if (!EncodeKeywords(is, sym_, &current_ids, &current_kws, &current_scores, 123 if (!EncodeKeywords(is, sym_, &current_ids, &current_kws, &current_scores,
124 &current_thresholds)) { 124 &current_thresholds)) {
125 #if __OHOS__ 125 #if __OHOS__
126 - SHERPA_ONNX_LOGE("Encode keywords %{public}s failed.", keywords.c_str()); 126 + SHERPA_ONNX_LOGE("Encode keywords '%{public}s' failed.",
  127 + keywords.c_str());
127 #else 128 #else
128 - SHERPA_ONNX_LOGE("Encode keywords %s failed.", keywords.c_str()); 129 + SHERPA_ONNX_LOGE("Encode keywords '%s' failed.", keywords.c_str());
129 #endif 130 #endif
130 return nullptr; 131 return nullptr;
131 } 132 }
@@ -303,10 +304,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl { @@ -303,10 +304,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl {
303 std::ifstream is(config_.keywords_file); 304 std::ifstream is(config_.keywords_file);
304 if (!is) { 305 if (!is) {
305 #if __OHOS__ 306 #if __OHOS__
306 - SHERPA_ONNX_LOGE("Open keywords file failed: %{public}s", 307 + SHERPA_ONNX_LOGE("Open keywords file failed: '%{public}s'",
307 config_.keywords_file.c_str()); 308 config_.keywords_file.c_str());
308 #else 309 #else
309 - SHERPA_ONNX_LOGE("Open keywords file failed: %s", 310 + SHERPA_ONNX_LOGE("Open keywords file failed: '%s'",
310 config_.keywords_file.c_str()); 311 config_.keywords_file.c_str());
311 #endif 312 #endif
312 exit(-1); 313 exit(-1);
@@ -325,10 +326,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl { @@ -325,10 +326,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl {
325 326
326 if (!is) { 327 if (!is) {
327 #if __OHOS__ 328 #if __OHOS__
328 - SHERPA_ONNX_LOGE("Open keywords file failed: %{public}s", 329 + SHERPA_ONNX_LOGE("Open keywords file failed: '%{public}s'",
329 config_.keywords_file.c_str()); 330 config_.keywords_file.c_str());
330 #else 331 #else
331 - SHERPA_ONNX_LOGE("Open keywords file failed: %s", 332 + SHERPA_ONNX_LOGE("Open keywords file failed: '%s'",
332 config_.keywords_file.c_str()); 333 config_.keywords_file.c_str());
333 #endif 334 #endif
334 exit(-1); 335 exit(-1);
@@ -156,7 +156,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl { @@ -156,7 +156,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl {
156 std::vector<float> current_scores; 156 std::vector<float> current_scores;
157 if (!EncodeHotwords(is, config_.model_config.modeling_unit, symbol_table_, 157 if (!EncodeHotwords(is, config_.model_config.modeling_unit, symbol_table_,
158 bpe_encoder_.get(), &current, &current_scores)) { 158 bpe_encoder_.get(), &current, &current_scores)) {
159 - SHERPA_ONNX_LOGE("Encode hotwords failed, skipping, hotwords are : %s", 159 + SHERPA_ONNX_LOGE("Encode hotwords failed, skipping, hotwords are : '%s'",
160 hotwords.c_str()); 160 hotwords.c_str());
161 } 161 }
162 162
@@ -252,7 +252,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl { @@ -252,7 +252,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl {
252 252
253 std::ifstream is(config_.hotwords_file); 253 std::ifstream is(config_.hotwords_file);
254 if (!is) { 254 if (!is) {
255 - SHERPA_ONNX_LOGE("Open hotwords file failed: %s", 255 + SHERPA_ONNX_LOGE("Open hotwords file failed: '%s'",
256 config_.hotwords_file.c_str()); 256 config_.hotwords_file.c_str());
257 exit(-1); 257 exit(-1);
258 } 258 }
@@ -276,7 +276,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl { @@ -276,7 +276,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl {
276 std::istringstream is(std::string(buf.begin(), buf.end())); 276 std::istringstream is(std::string(buf.begin(), buf.end()));
277 277
278 if (!is) { 278 if (!is) {
279 - SHERPA_ONNX_LOGE("Open hotwords file failed: %s", 279 + SHERPA_ONNX_LOGE("Open hotwords file failed: '%s'",
280 config_.hotwords_file.c_str()); 280 config_.hotwords_file.c_str());
281 exit(-1); 281 exit(-1);
282 } 282 }
@@ -78,12 +78,12 @@ bool WriteWave(const std::string &filename, int32_t sampling_rate, @@ -78,12 +78,12 @@ bool WriteWave(const std::string &filename, int32_t sampling_rate,
78 WriteWave(buffer.data(), sampling_rate, samples, n); 78 WriteWave(buffer.data(), sampling_rate, samples, n);
79 std::ofstream os(filename, std::ios::binary); 79 std::ofstream os(filename, std::ios::binary);
80 if (!os) { 80 if (!os) {
81 - SHERPA_ONNX_LOGE("Failed to create %s", filename.c_str()); 81 + SHERPA_ONNX_LOGE("Failed to create '%s'", filename.c_str());
82 return false; 82 return false;
83 } 83 }
84 os << buffer; 84 os << buffer;
85 if (!os) { 85 if (!os) {
86 - SHERPA_ONNX_LOGE("Write %s failed", filename.c_str()); 86 + SHERPA_ONNX_LOGE("Write '%s' failed", filename.c_str());
87 return false; 87 return false;
88 } 88 }
89 return true; 89 return true;