diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e61b1030..9ff8208c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,6 +84,12 @@ jobs: runs-on: windows-2022 steps: - uses: actions/checkout@v4 + - name: Setup Python 3.9.13 + uses: actions/setup-python@v5 + with: + python-version: '3.9.13' + architecture: 'x64' + - name: build_test shell: pwsh run: | @@ -93,6 +99,8 @@ jobs: export PATH=/usr/bin:/usr/lib:/usr/local/bin:/usr/local/lib:$PATH python -V python3 -V + python -m pip install --upgrade pip + python -m pip install timeout_decorator numpy onnxruntime pytest opencv-python setuptools echo $PATH echo "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" | sed 's/[^0-9A-Za-z]/^&/g' eval "$(./win_env/vcvarsall.sh x64)" @@ -113,8 +121,6 @@ jobs: cmake --build build_win_lite/x64-Release --config Release --target ALL_BUILD cp -r build_win_lite/x64-Release/output . set -e - python -m pip install --upgrade pip - python -m pip install timeout_decorator numpy onnxruntime pytest opencv-python export PYTHONHOME="$(dirname "$(which python)")" export C_INCLUDE_PATH=${C_INCLUDE_PATH}:$(pwd)/output/bmf/include export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:$(pwd)/output/bmf/include @@ -123,6 +129,7 @@ jobs: export PATH=$(pwd)/3rd_party/win_rootfs/x64/usr/bin:$(pwd)/3rd_party/win_rootfs/x64/usr/lib:$(pwd)/output/bmf/bin:$(pwd)/output/bmf/lib:${PATH} echo $PATH echo $(pwd) + ls output/bmf export HMP_TEST_DATA_ROOT=$(pwd)/bmf/hmp/tests/data ffmpeg -version module_manager help diff --git a/bmf/CMakeLists.txt b/bmf/CMakeLists.txt index 5eeebf87..bf37c826 100644 --- a/bmf/CMakeLists.txt +++ b/bmf/CMakeLists.txt @@ -3,6 +3,7 @@ add_subdirectory(sdk) #add_subdirectory(go_module_sdk) #FIXME: compile failed add_subdirectory(engine) add_subdirectory(c_modules) + if (NOT EMSCRIPTEN) add_subdirectory(python_modules) # XXX: no go modules now @@ -45,21 +46,12 @@ else() ) endif() -if(NOT WIN32) - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/__always_update - ${CMAKE_CURRENT_BINARY_DIR}/always_update - COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/always_update - ) -else() - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/__always_update - ${CMAKE_CURRENT_BINARY_DIR}/always_update - COMMAND copy /Y NUL \"${CMAKE_CURRENT_BINARY_DIR}/always_update\" - ) -endif() +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/__always_update + ${CMAKE_CURRENT_BINARY_DIR}/always_update + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/always_update +) function(copy_dir_to_bmf_module) if(ARGV1) @@ -81,17 +73,17 @@ if(NOT IOS) copy_dir_to_bmf_module(modules) copy_dir_to_bmf_module(python_sdk) copy_dir_to_bmf_module(server) - copy_dir_to_bmf_module(sdk/cpp_sdk/include include) copy_dir_to_bmf_module(engine/connector/include include) if(BMF_ENABLE_TEST) copy_dir_to_bmf_module(demo ../demo) copy_dir_to_bmf_module(test ../test) copy_dir_to_bmf_module(engine/c_engine/files files) endif() -else() - copy_dir_to_bmf_module(sdk/cpp_sdk/include include) endif() +copy_dir_to_bmf_module(sdk/cpp_sdk/include include) +copy_dir_to_bmf_module(cmd) + #### if(ANDROID) add_custom_command(TARGET bmf_assem @@ -149,7 +141,6 @@ endif() # COPY hmp related resources set(HMP_ROOT ${PROJECT_SOURCE_DIR}/bmf/hmp) - add_custom_command(TARGET bmf_assem POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BMF_ASSEMBLE_ROOT}/bmf/lib @@ -164,25 +155,19 @@ endif() ## copy symbol link of hmp and _jhmp if(NOT APPLE AND NOT ANDROID AND NOT EMSCRIPTEN) - if(WIN32) - add_custom_command(TARGET bmf_assem - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - $/${CMAKE_SHARED_LIBRARY_PREFIX}hmp${CMAKE_SHARED_LIBRARY_SUFFIX} ${BMF_ASSEMBLE_ROOT}/bmf/lib - ) - else() - add_custom_command(TARGET bmf_assem - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - $/${CMAKE_SHARED_LIBRARY_PREFIX}hmp${CMAKE_SHARED_LIBRARY_SUFFIX}* ${BMF_ASSEMBLE_ROOT}/bmf/lib - ) - endif() + add_custom_command(TARGET bmf_assem + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + $/ + ${BMF_ASSEMBLE_ROOT}/bmf/lib/ + ) if(BMF_ENABLE_JNI) add_custom_command(TARGET bmf_assem POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - $/${CMAKE_SHARED_LIBRARY_PREFIX}_jhmp${CMAKE_SHARED_LIBRARY_SUFFIX}* ${BMF_ASSEMBLE_ROOT}/bmf/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory + $/ + ${BMF_ASSEMBLE_ROOT}/bmf/lib/ ) endif() endif() @@ -226,7 +211,6 @@ if(TARGET _hmp) ${BMF_ASSEMBLE_ROOT}/bmf/hmp/) endif() - if(IOS) if(BUILD_SHARED_LIBS OR NOT BMF_LOCAL_DEPENDENCIES) message(FATAL_ERROR "Only support static build for IOS platform") diff --git a/bmf/__init__.py b/bmf/__init__.py index 46af70d5..4a9b987a 100644 --- a/bmf/__init__.py +++ b/bmf/__init__.py @@ -29,5 +29,7 @@ GraphConfig, get_module_file_dependencies, ff_filter from .server import ServerGateway, ServerGatewayNew +from .cmd import find_in_python_root, exec_cmd, run_bmf_graph, trace_format_log, module_manager, bmf_env + if platform.system().lower() != 'windows': sys.setdlopenflags(flags) diff --git a/bmf/cmd/CMakeLists.txt b/bmf/cmd/CMakeLists.txt index 0fd11ba2..a638f1da 100644 --- a/bmf/cmd/CMakeLists.txt +++ b/bmf/cmd/CMakeLists.txt @@ -41,10 +41,10 @@ target_link_libraries(module_manager ) # Build targets - install(TARGETS run_bmf_graph trace_format_log module_manager - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib + RUNTIME DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + LIBRARY DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + ARCHIVE DESTINATION ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} ) diff --git a/bmf/cmd/__init__.py b/bmf/cmd/__init__.py new file mode 100644 index 00000000..adbb9153 --- /dev/null +++ b/bmf/cmd/__init__.py @@ -0,0 +1 @@ +from .python_wrapper.wrapper import find_in_python_root, exec_cmd, run_bmf_graph, trace_format_log, module_manager, bmf_env \ No newline at end of file diff --git a/setup.py b/setup.py index 3403a4bc..e7e8786d 100644 --- a/setup.py +++ b/setup.py @@ -89,7 +89,7 @@ def build_extension(self, ext: CMakeExtension) -> None: # Can be set with Conda-Build, for example. cmake_generator = os.environ.get("CMAKE_GENERATOR", "") - sha = os.environ.get("GIT_SHA") + sha = os.environ.get("GIT_SHA", "") short_sha = sha[:7] # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON