Skip to content

Fix building wheels for macOS #2192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/build-wheels-macos-universal2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest]
os: [macos-13]
python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"]

steps:
Expand Down Expand Up @@ -88,7 +88,13 @@ jobs:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python3 -m pip install --break-system-packages --upgrade pip
python3 -m pip install --break-system-packages wheel twine==5.0.0 setuptools
opts='--break-system-packages'
v=${{ matrix.python-version }}
if [[ $v == cp38 || $v == cp39 ]]; then
opts=''
fi

python3 -m pip install $opts --upgrade pip
python3 -m pip install $opts wheel twine==5.0.0 setuptools

twine upload ./wheelhouse/*.whl
2 changes: 1 addition & 1 deletion sherpa-onnx/csrc/file-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ std::vector<char> ReadFile(AAssetManager *mgr, const std::string &filename) {
AAsset *asset = AAssetManager_open(mgr, filename.c_str(), AASSET_MODE_BUFFER);
if (!asset) {
__android_log_print(ANDROID_LOG_FATAL, "sherpa-onnx",
"Read binary file: Load %s failed", filename.c_str());
"Read binary file: Load '%s' failed", filename.c_str());
exit(-1);
}

Expand Down
13 changes: 7 additions & 6 deletions sherpa-onnx/csrc/keyword-spotter-transducer-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl {
if (!EncodeKeywords(is, sym_, &current_ids, &current_kws, &current_scores,
&current_thresholds)) {
#if __OHOS__
SHERPA_ONNX_LOGE("Encode keywords %{public}s failed.", keywords.c_str());
SHERPA_ONNX_LOGE("Encode keywords '%{public}s' failed.",
keywords.c_str());
#else
SHERPA_ONNX_LOGE("Encode keywords %s failed.", keywords.c_str());
SHERPA_ONNX_LOGE("Encode keywords '%s' failed.", keywords.c_str());
#endif
return nullptr;
}
Expand Down Expand Up @@ -303,10 +304,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl {
std::ifstream is(config_.keywords_file);
if (!is) {
#if __OHOS__
SHERPA_ONNX_LOGE("Open keywords file failed: %{public}s",
SHERPA_ONNX_LOGE("Open keywords file failed: '%{public}s'",
config_.keywords_file.c_str());
#else
SHERPA_ONNX_LOGE("Open keywords file failed: %s",
SHERPA_ONNX_LOGE("Open keywords file failed: '%s'",
config_.keywords_file.c_str());
#endif
exit(-1);
Expand All @@ -325,10 +326,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl {

if (!is) {
#if __OHOS__
SHERPA_ONNX_LOGE("Open keywords file failed: %{public}s",
SHERPA_ONNX_LOGE("Open keywords file failed: '%{public}s'",
config_.keywords_file.c_str());
#else
SHERPA_ONNX_LOGE("Open keywords file failed: %s",
SHERPA_ONNX_LOGE("Open keywords file failed: '%s'",
config_.keywords_file.c_str());
#endif
exit(-1);
Expand Down
6 changes: 3 additions & 3 deletions sherpa-onnx/csrc/offline-recognizer-transducer-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl {
std::vector<float> current_scores;
if (!EncodeHotwords(is, config_.model_config.modeling_unit, symbol_table_,
bpe_encoder_.get(), &current, &current_scores)) {
SHERPA_ONNX_LOGE("Encode hotwords failed, skipping, hotwords are : %s",
SHERPA_ONNX_LOGE("Encode hotwords failed, skipping, hotwords are : '%s'",
hotwords.c_str());
}

Expand Down Expand Up @@ -252,7 +252,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl {

std::ifstream is(config_.hotwords_file);
if (!is) {
SHERPA_ONNX_LOGE("Open hotwords file failed: %s",
SHERPA_ONNX_LOGE("Open hotwords file failed: '%s'",
config_.hotwords_file.c_str());
exit(-1);
}
Expand All @@ -276,7 +276,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl {
std::istringstream is(std::string(buf.begin(), buf.end()));

if (!is) {
SHERPA_ONNX_LOGE("Open hotwords file failed: %s",
SHERPA_ONNX_LOGE("Open hotwords file failed: '%s'",
config_.hotwords_file.c_str());
exit(-1);
}
Expand Down
4 changes: 2 additions & 2 deletions sherpa-onnx/csrc/wave-writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ bool WriteWave(const std::string &filename, int32_t sampling_rate,
WriteWave(buffer.data(), sampling_rate, samples, n);
std::ofstream os(filename, std::ios::binary);
if (!os) {
SHERPA_ONNX_LOGE("Failed to create %s", filename.c_str());
SHERPA_ONNX_LOGE("Failed to create '%s'", filename.c_str());
return false;
}
os << buffer;
if (!os) {
SHERPA_ONNX_LOGE("Write %s failed", filename.c_str());
SHERPA_ONNX_LOGE("Write '%s' failed", filename.c_str());
return false;
}
return true;
Expand Down
Loading