Committed by
GitHub
Fix issues about DLLs when installing pre-compiled wheels on windows (#91)
正在显示
7 个修改的文件
包含
97 行增加
和
6 行删除
.github/workflows/test-pip-install.yaml
0 → 100644
| 1 | +name: test-pip-install | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + push: | ||
| 5 | + branches: | ||
| 6 | + - test-pip-install | ||
| 7 | + schedule: | ||
| 8 | + # minute (0-59) | ||
| 9 | + # hour (0-23) | ||
| 10 | + # day of the month (1-31) | ||
| 11 | + # month (1-12) | ||
| 12 | + # day of the week (0-6) | ||
| 13 | + # nightly build at 23:50 UTC time every day | ||
| 14 | + - cron: "50 23 * * *" | ||
| 15 | + | ||
| 16 | +concurrency: | ||
| 17 | + group: test-pip-install-${{ github.ref }} | ||
| 18 | + cancel-in-progress: true | ||
| 19 | + | ||
| 20 | +permissions: | ||
| 21 | + contents: read | ||
| 22 | + | ||
| 23 | +jobs: | ||
| 24 | + test_pip_install: | ||
| 25 | + runs-on: ${{ matrix.os }} | ||
| 26 | + name: Test pip install on ${{ matrix.os }} | ||
| 27 | + strategy: | ||
| 28 | + fail-fast: false | ||
| 29 | + matrix: | ||
| 30 | + os: [ubuntu-latest, windows-latest, macos-latest] | ||
| 31 | + python-version: ["3.7", "3.8", "3.9", "3.10"] | ||
| 32 | + | ||
| 33 | + steps: | ||
| 34 | + - uses: actions/checkout@v2 | ||
| 35 | + with: | ||
| 36 | + fetch-depth: 0 | ||
| 37 | + | ||
| 38 | + - name: Setup Python ${{ matrix.python-version }} | ||
| 39 | + uses: actions/setup-python@v2 | ||
| 40 | + with: | ||
| 41 | + python-version: ${{ matrix.python-version }} | ||
| 42 | + | ||
| 43 | + - name: Install sherpa-onnx | ||
| 44 | + shell: bash | ||
| 45 | + run: | | ||
| 46 | + pip install --verbose sherpa-onnx | ||
| 47 | + | ||
| 48 | + - name: Test sherp-onnx | ||
| 49 | + shell: bash | ||
| 50 | + run: | | ||
| 51 | + python3 -c "import sherpa_onnx; print(sherpa_onnx.__file__)" | ||
| 52 | + python3 -c "import sherpa_onnx; print(sherpa_onnx.__version__)" |
| 1 | cmake_minimum_required(VERSION 3.13 FATAL_ERROR) | 1 | cmake_minimum_required(VERSION 3.13 FATAL_ERROR) |
| 2 | project(sherpa-onnx) | 2 | project(sherpa-onnx) |
| 3 | 3 | ||
| 4 | -set(SHERPA_ONNX_VERSION "1.3.0") | 4 | +set(SHERPA_ONNX_VERSION "1.3.2") |
| 5 | 5 | ||
| 6 | # Disable warning about | 6 | # Disable warning about |
| 7 | # | 7 | # |
| @@ -74,9 +74,37 @@ endif() | @@ -74,9 +74,37 @@ endif() | ||
| 74 | check_include_file_cxx(cxxabi.h SHERPA_ONNX_HAVE_CXXABI_H) | 74 | check_include_file_cxx(cxxabi.h SHERPA_ONNX_HAVE_CXXABI_H) |
| 75 | check_include_file_cxx(execinfo.h SHERPA_ONNX_HAVE_EXECINFO_H) | 75 | check_include_file_cxx(execinfo.h SHERPA_ONNX_HAVE_EXECINFO_H) |
| 76 | 76 | ||
| 77 | +if(WIN32) | ||
| 78 | + add_definitions(-DNOMINMAX) # Otherwise, std::max() and std::min() won't work | ||
| 79 | +endif() | ||
| 80 | + | ||
| 81 | +if(WIN32 AND MSVC) | ||
| 82 | + # disable various warnings for MSVC | ||
| 83 | + # 4244: 'return': conversion from 'unsigned __int64' to 'int', possible loss of data | ||
| 84 | + # 4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data | ||
| 85 | + # 4305: 'argument': truncation from 'double' to 'const float' | ||
| 86 | + # 4334: '<<': result of 32-bit shift implicitly converted to 64 bits | ||
| 87 | + # 4800: 'int': forcing value to bool 'true' or 'false' | ||
| 88 | + # 4996: 'fopen': This function or variable may be unsafe | ||
| 89 | + set(disabled_warnings | ||
| 90 | + /wd4244 | ||
| 91 | + /wd4267 | ||
| 92 | + /wd4305 | ||
| 93 | + /wd4334 | ||
| 94 | + /wd4800 | ||
| 95 | + /wd4996 | ||
| 96 | + ) | ||
| 97 | + message(STATUS "Disabled warnings: ${disabled_warnings}") | ||
| 98 | + foreach(w IN LISTS disabled_warnings) | ||
| 99 | + string(APPEND CMAKE_CXX_FLAGS " ${w} ") | ||
| 100 | + endforeach() | ||
| 101 | +endif() | ||
| 102 | + | ||
| 103 | + | ||
| 77 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) | 104 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) |
| 78 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | 105 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) |
| 79 | 106 | ||
| 107 | + | ||
| 80 | include(kaldi-native-fbank) | 108 | include(kaldi-native-fbank) |
| 81 | include(onnxruntime) | 109 | include(onnxruntime) |
| 82 | 110 |
| @@ -71,10 +71,8 @@ class BuildExtension(build_ext): | @@ -71,10 +71,8 @@ class BuildExtension(build_ext): | ||
| 71 | cmake_args = "-DCMAKE_BUILD_TYPE=Release" | 71 | cmake_args = "-DCMAKE_BUILD_TYPE=Release" |
| 72 | 72 | ||
| 73 | extra_cmake_args = f" -DCMAKE_INSTALL_PREFIX={install_dir} " | 73 | extra_cmake_args = f" -DCMAKE_INSTALL_PREFIX={install_dir} " |
| 74 | - if not is_windows(): | ||
| 75 | extra_cmake_args += " -DBUILD_SHARED_LIBS=ON " | 74 | extra_cmake_args += " -DBUILD_SHARED_LIBS=ON " |
| 76 | - else: | ||
| 77 | - extra_cmake_args += " -DBUILD_SHARED_LIBS=OFF " | 75 | + |
| 78 | extra_cmake_args += " -DSHERPA_ONNX_ENABLE_CHECK=OFF " | 76 | extra_cmake_args += " -DSHERPA_ONNX_ENABLE_CHECK=OFF " |
| 79 | extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PYTHON=ON " | 77 | extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PYTHON=ON " |
| 80 | extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF " | 78 | extra_cmake_args += " -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF " |
| @@ -49,7 +49,11 @@ function(download_kaldi_native_fbank) | @@ -49,7 +49,11 @@ function(download_kaldi_native_fbank) | ||
| 49 | INTERFACE | 49 | INTERFACE |
| 50 | ${kaldi_native_fbank_SOURCE_DIR}/ | 50 | ${kaldi_native_fbank_SOURCE_DIR}/ |
| 51 | ) | 51 | ) |
| 52 | + if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32) | ||
| 53 | + install(TARGETS kaldi-native-fbank-core DESTINATION ..) | ||
| 54 | + else() | ||
| 52 | install(TARGETS kaldi-native-fbank-core DESTINATION lib) | 55 | install(TARGETS kaldi-native-fbank-core DESTINATION lib) |
| 56 | + endif() | ||
| 53 | endfunction() | 57 | endfunction() |
| 54 | 58 | ||
| 55 | download_kaldi_native_fbank() | 59 | download_kaldi_native_fbank() |
| @@ -155,7 +155,11 @@ function(download_onnxruntime) | @@ -155,7 +155,11 @@ function(download_onnxruntime) | ||
| 155 | endif() | 155 | endif() |
| 156 | 156 | ||
| 157 | message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") | 157 | message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") |
| 158 | + if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32) | ||
| 159 | + install(FILES ${onnxruntime_lib_files} DESTINATION ..) | ||
| 160 | + else() | ||
| 158 | install(FILES ${onnxruntime_lib_files} DESTINATION lib) | 161 | install(FILES ${onnxruntime_lib_files} DESTINATION lib) |
| 162 | + endif() | ||
| 159 | endfunction() | 163 | endfunction() |
| 160 | 164 | ||
| 161 | # First, we try to locate the header and the lib if the use has already | 165 | # First, we try to locate the header and the lib if the use has already |
| @@ -62,7 +62,12 @@ if(NOT WIN32) | @@ -62,7 +62,12 @@ if(NOT WIN32) | ||
| 62 | target_link_libraries(sherpa-onnx "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib") | 62 | target_link_libraries(sherpa-onnx "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib") |
| 63 | endif() | 63 | endif() |
| 64 | 64 | ||
| 65 | -install(TARGETS sherpa-onnx-core DESTINATION lib) | 65 | +if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32) |
| 66 | + install(TARGETS sherpa-onnx-core DESTINATION ..) | ||
| 67 | +else() | ||
| 68 | + install(TARGETS sherpa-onnx-core DESTINATION lib) | ||
| 69 | +endif() | ||
| 70 | + | ||
| 66 | install(TARGETS sherpa-onnx DESTINATION bin) | 71 | install(TARGETS sherpa-onnx DESTINATION bin) |
| 67 | 72 | ||
| 68 | if(SHERPA_ONNX_HAS_ALSA) | 73 | if(SHERPA_ONNX_HAS_ALSA) |
-
请 注册 或 登录 后发表评论