diff --git a/.github/workflows/test-pip-install.yaml b/.github/workflows/test-pip-install.yaml new file mode 100644 index 00000000..9b7d7cc6 --- /dev/null +++ b/.github/workflows/test-pip-install.yaml @@ -0,0 +1,52 @@ +name: test-pip-install + +on: + push: + branches: + - test-pip-install + schedule: + # minute (0-59) + # hour (0-23) + # day of the month (1-31) + # month (1-12) + # day of the week (0-6) + # nightly build at 23:50 UTC time every day + - cron: "50 23 * * *" + +concurrency: + group: test-pip-install-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + test_pip_install: + runs-on: ${{ matrix.os }} + name: Test pip install on ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.7", "3.8", "3.9", "3.10"] + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install sherpa-onnx + shell: bash + run: | + pip install --verbose sherpa-onnx + + - name: Test sherp-onnx + shell: bash + run: | + python3 -c "import sherpa_onnx; print(sherpa_onnx.__file__)" + python3 -c "import sherpa_onnx; print(sherpa_onnx.__version__)" diff --git a/CMakeLists.txt b/CMakeLists.txt index 34b259f2..9b5601cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR) project(sherpa-onnx) -set(SHERPA_ONNX_VERSION "1.3.0") +set(SHERPA_ONNX_VERSION "1.3.2") # Disable warning about # @@ -74,9 +74,37 @@ endif() check_include_file_cxx(cxxabi.h SHERPA_ONNX_HAVE_CXXABI_H) check_include_file_cxx(execinfo.h SHERPA_ONNX_HAVE_EXECINFO_H) +if(WIN32) + add_definitions(-DNOMINMAX) # Otherwise, std::max() and std::min() won't work +endif() + +if(WIN32 AND MSVC) + # disable various warnings for MSVC + # 4244: 'return': conversion from 'unsigned __int64' to 'int', possible loss of data + # 4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data + # 4305: 'argument': truncation from 'double' to 'const float' + # 4334: '<<': result of 32-bit shift implicitly converted to 64 bits + # 4800: 'int': forcing value to bool 'true' or 'false' + # 4996: 'fopen': This function or variable may be unsafe + set(disabled_warnings + /wd4244 + /wd4267 + /wd4305 + /wd4334 + /wd4800 + /wd4996 + ) + message(STATUS "Disabled warnings: ${disabled_warnings}") + foreach(w IN LISTS disabled_warnings) + string(APPEND CMAKE_CXX_FLAGS " ${w} ") + endforeach() +endif() + + list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + include(kaldi-native-fbank) include(onnxruntime) diff --git a/cmake/cmake_extension.py b/cmake/cmake_extension.py index 4c56bc68..979c4624 100644 --- a/cmake/cmake_extension.py +++ b/cmake/cmake_extension.py @@ -71,10 +71,8 @@ class BuildExtension(build_ext): cmake_args = "-DCMAKE_BUILD_TYPE=Release" extra_cmake_args = f" -DCMAKE_INSTALL_PREFIX={install_dir} " - if not is_windows(): - extra_cmake_args += " -DBUILD_SHARED_LIBS=ON " - else: - extra_cmake_args += " -DBUILD_SHARED_LIBS=OFF " + extra_cmake_args += " -DBUILD_SHARED_LIBS=ON " + extra_cmake_args += " -DSHERPA_ONNX_ENABLE_CHECK=OFF " extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PYTHON=ON " extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF " diff --git a/cmake/kaldi-native-fbank.cmake b/cmake/kaldi-native-fbank.cmake index 2246d6e2..a968bf24 100644 --- a/cmake/kaldi-native-fbank.cmake +++ b/cmake/kaldi-native-fbank.cmake @@ -49,7 +49,11 @@ function(download_kaldi_native_fbank) INTERFACE ${kaldi_native_fbank_SOURCE_DIR}/ ) - install(TARGETS kaldi-native-fbank-core DESTINATION lib) + if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32) + install(TARGETS kaldi-native-fbank-core DESTINATION ..) + else() + install(TARGETS kaldi-native-fbank-core DESTINATION lib) + endif() endfunction() download_kaldi_native_fbank() diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake index 573977af..8001c05b 100644 --- a/cmake/onnxruntime.cmake +++ b/cmake/onnxruntime.cmake @@ -155,7 +155,11 @@ function(download_onnxruntime) endif() message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") - install(FILES ${onnxruntime_lib_files} DESTINATION lib) + if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32) + install(FILES ${onnxruntime_lib_files} DESTINATION ..) + else() + install(FILES ${onnxruntime_lib_files} DESTINATION lib) + endif() endfunction() # First, we try to locate the header and the lib if the use has already diff --git a/sherpa-onnx/csrc/CMakeLists.txt b/sherpa-onnx/csrc/CMakeLists.txt index 0f0626e1..a44f6678 100644 --- a/sherpa-onnx/csrc/CMakeLists.txt +++ b/sherpa-onnx/csrc/CMakeLists.txt @@ -62,7 +62,12 @@ if(NOT WIN32) target_link_libraries(sherpa-onnx "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib") endif() -install(TARGETS sherpa-onnx-core DESTINATION lib) +if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32) + install(TARGETS sherpa-onnx-core DESTINATION ..) +else() + install(TARGETS sherpa-onnx-core DESTINATION lib) +endif() + install(TARGETS sherpa-onnx DESTINATION bin) if(SHERPA_ONNX_HAS_ALSA) diff --git a/sherpa-onnx/csrc/online-transducer-model.h b/sherpa-onnx/csrc/online-transducer-model.h index 42e7948b..3a034516 100644 --- a/sherpa-onnx/csrc/online-transducer-model.h +++ b/sherpa-onnx/csrc/online-transducer-model.h @@ -20,7 +20,7 @@ namespace sherpa_onnx { -class OnlineTransducerDecoderResult; +struct OnlineTransducerDecoderResult; class OnlineTransducerModel { public: