From 4bc24f540b2495b3232b7a240eead70cc7ea6f96 Mon Sep 17 00:00:00 2001 From: luncliff Date: Mon, 13 Jan 2025 20:58:31 +0900 Subject: [PATCH 1/8] [onnx] use "vcpkg-get-python-packages" instead of "python3" dependency * use requiremens-min.txt to install other python dependencies * get pybind11 directory in portfile.cmake --- ports/onnx/fix-cmakelists.patch | 48 ++++++++++++++++++++++----------- ports/onnx/portfile.cmake | 32 +++++++++++----------- ports/onnx/vcpkg.json | 11 ++++---- 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/ports/onnx/fix-cmakelists.patch b/ports/onnx/fix-cmakelists.patch index f8d300103ab205..b3f490096be2d9 100644 --- a/ports/onnx/fix-cmakelists.patch +++ b/ports/onnx/fix-cmakelists.patch @@ -1,8 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 4dd56b6..2ff3e29 100644 +index b666eec..66c234d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -65,6 +65,27 @@ endif() +@@ -63,6 +63,27 @@ endif() include(GNUInstallDirs) @@ -30,7 +30,7 @@ index 4dd56b6..2ff3e29 100644 set(ONNX_ROOT ${PROJECT_SOURCE_DIR}) # Read ONNX version -@@ -116,7 +137,8 @@ endif() +@@ -104,7 +125,8 @@ endif() # find_package Python has replaced PythonInterp and PythonLibs since cmake 3.12 # Use the following command in the future; now this is only compatible with the latest pybind11 # find_package(Python ${PY_VERSION} COMPONENTS Interpreter Development REQUIRED) @@ -40,7 +40,7 @@ index 4dd56b6..2ff3e29 100644 if(BUILD_ONNX_PYTHON) find_package(PythonLibs ${PY_VERSION}) endif() -@@ -434,6 +456,7 @@ target_link_libraries(onnx PUBLIC onnx_proto) +@@ -534,6 +556,7 @@ target_link_libraries(onnx PUBLIC onnx_proto) add_onnx_global_defines(onnx) if(BUILD_ONNX_PYTHON) @@ -48,20 +48,38 @@ index 4dd56b6..2ff3e29 100644 if("${PY_EXT_SUFFIX}" STREQUAL "") if(MSVC) set(PY_EXT_SUFFIX ".pyd") -@@ -452,10 +475,14 @@ if(BUILD_ONNX_PYTHON) +@@ -542,7 +565,9 @@ if(BUILD_ONNX_PYTHON) + endif() + endif() + +- add_library(onnx_cpp2py_export MODULE "${ONNX_ROOT}/onnx/cpp2py_export.cc") ++ find_package(pybind11 2.2 CONFIG REQUIRED) ++ pybind11_add_module(onnx_cpp2py_export MODULE "${ONNX_ROOT}/onnx/cpp2py_export.cc") ++ install(TARGETS onnx_cpp2py_export DESTINATION ${CMAKE_INSTALL_LIBDIR}) + set_target_properties(onnx_cpp2py_export PROPERTIES PREFIX "") + set_target_properties(onnx_cpp2py_export + PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") +@@ -552,19 +577,10 @@ if(BUILD_ONNX_PYTHON) target_include_directories(onnx_cpp2py_export PRIVATE $ $ - $) +- +- # pybind11 is a header only lib +- find_package(pybind11 2.2 CONFIG) +- if(NOT pybind11_FOUND) +- if(EXISTS "${ONNX_ROOT}/third_party/pybind11/include/pybind11/pybind11.h") +- add_subdirectory("${ONNX_ROOT}/third_party/pybind11") +- else() +- message(FATAL_ERROR "cannot find pybind") +- endif() +- endif() +- +- target_include_directories(onnx_cpp2py_export PUBLIC + ${Python3_INCLUDE_DIRS}) -+ target_link_directories(onnx_cpp2py_export PRIVATE -+ ${Python3_LIBRARY_DIRS}) -+ target_link_libraries(onnx_cpp2py_export PRIVATE -+ ${Python3_LIBRARIES}) ++ target_link_directories(onnx_cpp2py_export PRIVATE ${Python3_LIBRARY_DIRS}) ++ target_link_libraries(onnx_cpp2py_export PRIVATE ${Python3_LIBRARIES}) ++ target_include_directories(onnx_cpp2py_export PRIVATE + "${pybind11_INCLUDE_DIRS}" + "${PYTHON_INCLUDE_DIRS}") - # pybind11 is a header only lib -- find_package(pybind11 2.2 CONFIG) -+ find_package(pybind11 2.2 CONFIG REQUIRED) - if(NOT pybind11_FOUND) - if(EXISTS "${ONNX_ROOT}/third_party/pybind11/include/pybind11/pybind11.h") - add_subdirectory("${ONNX_ROOT}/third_party/pybind11") diff --git a/ports/onnx/portfile.cmake b/ports/onnx/portfile.cmake index 668425d3223791..3aaf783dc2ea0f 100644 --- a/ports/onnx/portfile.cmake +++ b/ports/onnx/portfile.cmake @@ -27,24 +27,31 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS ) # Like protoc, python is required for codegen. -vcpkg_find_acquire_program(PYTHON3) +if("pybind11" IN_LIST FEATURES) + x_vcpkg_get_python_packages(PYTHON_VERSION 3 + REQUIREMENTS_FILE "${SOURCE_PATH}/requirements-min.txt" + PACKAGES "pybind11" + OUT_PYTHON_VAR PYTHON3 + ) + execute_process( + COMMAND "${PYTHON3}" -c "import site; print(site.getsitepackages()[0])" + OUTPUT_VARIABLE SITE_PACKAGES_DIR OUTPUT_STRIP_TRAILING_WHITESPACE + ) + find_path(pybind11_DIR NAMES pybind11Config.cmake PATHS "${SITE_PACKAGES_DIR}" "${SITE_PACKAGES_DIR}/Lib/site-packages" PATH_SUFFIXES "pybind11/share/cmake/pybind11" REQUIRED NO_DEFAULT_PATH) + list(APPEND FEATURE_OPTIONS "-Dpybind11_DIR:PATH=${pybind11_DIR}") +else() + vcpkg_find_acquire_program(PYTHON3) +endif() # PATH for .bat scripts so it can find 'python' get_filename_component(PYTHON_DIR "${PYTHON3}" PATH) vcpkg_add_to_path(PREPEND "${PYTHON_DIR}") -if("pybind11" IN_LIST FEATURES) - # When BUILD_ONNX_PYTHON, we need Development component. Give a hint for FindPython3 - list(APPEND FEATURE_OPTIONS - "-DPython3_ROOT_DIR=${CURRENT_INSTALLED_DIR}" - ) -endif() - vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS ${FEATURE_OPTIONS} - -DPython3_EXECUTABLE=${PYTHON3} + "-DPython3_EXECUTABLE=${PYTHON3}" -DONNX_ML=ON -DONNX_GEN_PB_TYPE_STUBS=ON -DONNX_USE_PROTOBUF_SHARED_LIBS=${USE_PROTOBUF_SHARED} @@ -55,13 +62,8 @@ vcpkg_cmake_configure( MAYBE_UNUSED_VARIABLES ONNX_USE_MSVC_STATIC_RUNTIME ) - -if("pybind11" IN_LIST FEATURES) - # This target is not in install/export - vcpkg_cmake_build(TARGET onnx_cpp2py_export) -endif() vcpkg_cmake_install() -vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ONNX) +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ONNX PACKAGE_NAME ONNX) vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/ports/onnx/vcpkg.json b/ports/onnx/vcpkg.json index ada26a3f2694f1..dc376dc53b901c 100644 --- a/ports/onnx/vcpkg.json +++ b/ports/onnx/vcpkg.json @@ -1,7 +1,7 @@ { "name": "onnx", "version-semver": "1.16.2", - "port-version": 1, + "port-version": 2, "description": "Open standard for machine learning interoperability", "homepage": "https://onnx.ai", "license": "Apache-2.0", @@ -12,10 +12,6 @@ "name": "protobuf", "host": true }, - { - "name": "python3", - "host": true - }, { "name": "vcpkg-cmake", "host": true @@ -29,7 +25,10 @@ "pybind11": { "description": "Build Python binaries", "dependencies": [ - "pybind11" + { + "name": "vcpkg-get-python-packages", + "host": true + } ] } } From 3663a9a1b30329045bbf8f376e486527003e520e Mon Sep 17 00:00:00 2001 From: luncliff Date: Mon, 13 Jan 2025 20:58:46 +0900 Subject: [PATCH 2/8] [onnx] update baseline --- versions/baseline.json | 2 +- versions/o-/onnx.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index ae7edec66224fa..b30d3c1eb1bca1 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6614,7 +6614,7 @@ }, "onnx": { "baseline": "1.16.2", - "port-version": 1 + "port-version": 2 }, "onnx-optimizer": { "baseline": "0.3.19", diff --git a/versions/o-/onnx.json b/versions/o-/onnx.json index 494dd57dbdf0d3..a38240c26c40bc 100644 --- a/versions/o-/onnx.json +++ b/versions/o-/onnx.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "1d55dc05e9a916787d89fdfe190057ba2a96ec18", + "version-semver": "1.16.2", + "port-version": 2 + }, { "git-tree": "262df4daa9534c3c514b1a4f7c048369b575568f", "version-semver": "1.16.2", From 52a013a2e5311b189ecdf9df5421c5d4eb7b6a36 Mon Sep 17 00:00:00 2001 From: luncliff Date: Mon, 13 Jan 2025 21:22:05 +0900 Subject: [PATCH 3/8] [onnx] support UWP build --- ports/onnx/portfile.cmake | 3 +-- ports/onnx/vcpkg.json | 1 - versions/o-/onnx.json | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ports/onnx/portfile.cmake b/ports/onnx/portfile.cmake index 3aaf783dc2ea0f..75d8f7361f46b9 100644 --- a/ports/onnx/portfile.cmake +++ b/ports/onnx/portfile.cmake @@ -28,10 +28,9 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS # Like protoc, python is required for codegen. if("pybind11" IN_LIST FEATURES) - x_vcpkg_get_python_packages(PYTHON_VERSION 3 + x_vcpkg_get_python_packages(PYTHON_VERSION 3 OUT_PYTHON_VAR PYTHON3 REQUIREMENTS_FILE "${SOURCE_PATH}/requirements-min.txt" PACKAGES "pybind11" - OUT_PYTHON_VAR PYTHON3 ) execute_process( COMMAND "${PYTHON3}" -c "import site; print(site.getsitepackages()[0])" diff --git a/ports/onnx/vcpkg.json b/ports/onnx/vcpkg.json index dc376dc53b901c..3f1b022a4f17c0 100644 --- a/ports/onnx/vcpkg.json +++ b/ports/onnx/vcpkg.json @@ -5,7 +5,6 @@ "description": "Open standard for machine learning interoperability", "homepage": "https://onnx.ai", "license": "Apache-2.0", - "supports": "!uwp", "dependencies": [ "protobuf", { diff --git a/versions/o-/onnx.json b/versions/o-/onnx.json index a38240c26c40bc..4c388a9c6d350d 100644 --- a/versions/o-/onnx.json +++ b/versions/o-/onnx.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "1d55dc05e9a916787d89fdfe190057ba2a96ec18", + "git-tree": "69cc51c9965dee6c3990ccbf4c8a24d178e39b72", "version-semver": "1.16.2", "port-version": 2 }, From 390c583c7d6ee2e707081dd1d6abf143b9b0913f Mon Sep 17 00:00:00 2001 From: luncliff Date: Mon, 20 Jan 2025 21:57:07 +0900 Subject: [PATCH 4/8] [onnx-optimizer] remove pybind11 feature --- ports/onnx-optimizer/fix-cmakelists.patch | 34 ++--------------------- ports/onnx-optimizer/portfile.cmake | 17 +----------- ports/onnx-optimizer/vcpkg.json | 16 ++--------- 3 files changed, 5 insertions(+), 62 deletions(-) diff --git a/ports/onnx-optimizer/fix-cmakelists.patch b/ports/onnx-optimizer/fix-cmakelists.patch index e590b400f8d9a7..d98ed10920cd3b 100644 --- a/ports/onnx-optimizer/fix-cmakelists.patch +++ b/ports/onnx-optimizer/fix-cmakelists.patch @@ -42,36 +42,6 @@ index 0063385..f1522bc 100644 target_include_directories(onnx_optimizer PUBLIC $ $ -@@ -70,7 +77,7 @@ if(BUILD_ONNX_PYTHON) - set(PY_EXT_SUFFIX ".so") - endif() - endif() -- find_package(Python COMPONENTS Interpreter REQUIRED) -+ find_package(Python3 COMPONENTS Development REQUIRED) - - onnxopt_add_library(onnx_opt_cpp2py_export MODULE "onnxoptimizer/cpp2py_export.cc") - set_target_properties(onnx_opt_cpp2py_export PROPERTIES PREFIX "") -@@ -84,7 +91,7 @@ if(BUILD_ONNX_PYTHON) - $ - ${Python_INCLUDE_DIR}) - # pybind11 is a header only lib -- find_package(pybind11 2.2) -+ find_package(pybind11 2.2 CONFIG REQUIRED) - if(pybind11_FOUND) - target_include_directories(onnx_opt_cpp2py_export PUBLIC - ${pybind11_INCLUDE_DIRS}) -@@ -121,9 +128,9 @@ if(BUILD_ONNX_PYTHON) - - target_link_libraries(onnx_opt_cpp2py_export PRIVATE onnx_optimizer) - -+ target_link_directories(onnx_opt_cpp2py_export PRIVATE ${Python3_LIBRARY_DIRS}) -+ target_link_libraries(onnx_opt_cpp2py_export PRIVATE ${Python3_LIBRARIES}) - if(MSVC) -- find_package(Python COMPONENTS Interpreter Development REQUIRED) -- target_link_libraries(onnx_opt_cpp2py_export PRIVATE ${Python_LIBRARIES}) - target_compile_options(onnx_opt_cpp2py_export - PRIVATE /MP - /WX diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 6cca9f3..9d79f1a 100644 --- a/cmake/utils.cmake @@ -91,8 +61,8 @@ index 72dcc88..c5639c8 100644 # as well as ONNX Optimizer targets for other cmake libraries to use. +include(CMakeFindDependencyMacro) -+find_dependency(onnx CONFIG) -+ ++find_dependency(protobuf CONFIG) ++find_dependency(ONNX CONFIG) # library version information set(ONNX_OPTIMIZER_VERSION "@ONNX_OPTIMIZER_VERSION@") diff --git a/ports/onnx-optimizer/portfile.cmake b/ports/onnx-optimizer/portfile.cmake index 10e8d7fe78ea60..ce07fb395ff9af 100644 --- a/ports/onnx-optimizer/portfile.cmake +++ b/ports/onnx-optimizer/portfile.cmake @@ -12,30 +12,15 @@ vcpkg_from_github( string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME) -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - pybind11 BUILD_ONNX_PYTHON -) -if("pybind11" IN_LIST FEATURES) - vcpkg_find_acquire_program(PYTHON3) - list(APPEND FEATURE_OPTIONS - -DPython3_EXECUTABLE=${PYTHON3} - -DONNX_USE_PROTOBUF_SHARED_LIBS=ON # /wd4251 - ) -endif() vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS ${FEATURE_OPTIONS} + -DONNX_OPT_USE_SYSTEM_PROTOBUF=ON -DONNX_USE_MSVC_STATIC_RUNTIME=${USE_STATIC_RUNTIME} ) -if("pybind11" IN_LIST FEATURES) - # This target is not in install/export - vcpkg_cmake_build(TARGET onnx_opt_cpp2py_export) -endif() vcpkg_cmake_install() -vcpkg_copy_pdbs() vcpkg_cmake_config_fixup(PACKAGE_NAME ONNXOptimizer CONFIG_PATH lib/cmake/ONNXOptimizer) vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/ports/onnx-optimizer/vcpkg.json b/ports/onnx-optimizer/vcpkg.json index 9ca4a5e77a2a0f..33eeb618d3ec98 100644 --- a/ports/onnx-optimizer/vcpkg.json +++ b/ports/onnx-optimizer/vcpkg.json @@ -1,6 +1,7 @@ { "name": "onnx-optimizer", "version-semver": "0.3.19", + "port-version": 1, "description": "Actively maintained ONNX Optimizer", "homepage": "https://github.com/onnx/optimizer", "license": "Apache-2.0", @@ -14,18 +15,5 @@ "name": "vcpkg-cmake-config", "host": true } - ], - "features": { - "pybind11": { - "description": "Build Python binaries", - "dependencies": [ - { - "name": "onnx", - "features": [ - "pybind11" - ] - } - ] - } - } + ] } From 1a39b29f7f295900dc0d8b88f312145680f70f15 Mon Sep 17 00:00:00 2001 From: luncliff Date: Mon, 20 Jan 2025 21:58:44 +0900 Subject: [PATCH 5/8] [onnx-optimizer] update baseline --- vcpkg-registry | 1 + versions/baseline.json | 2 +- versions/o-/onnx-optimizer.json | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 160000 vcpkg-registry diff --git a/vcpkg-registry b/vcpkg-registry new file mode 160000 index 00000000000000..02a0a60c0db67a --- /dev/null +++ b/vcpkg-registry @@ -0,0 +1 @@ +Subproject commit 02a0a60c0db67a68f603b5d26f60d3281c1f5ecf diff --git a/versions/baseline.json b/versions/baseline.json index b30d3c1eb1bca1..f829b4bcf24a18 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6618,7 +6618,7 @@ }, "onnx-optimizer": { "baseline": "0.3.19", - "port-version": 0 + "port-version": 1 }, "onnxruntime-gpu": { "baseline": "1.19.2", diff --git a/versions/o-/onnx-optimizer.json b/versions/o-/onnx-optimizer.json index 21ff564b1714cc..4612549bc9b754 100644 --- a/versions/o-/onnx-optimizer.json +++ b/versions/o-/onnx-optimizer.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "df755dc18bda1d4c02a54db6cef63e46021ce872", + "version-semver": "0.3.19", + "port-version": 1 + }, { "git-tree": "126bfc519dc0c50fc52ed0b19a0bd88663bae87f", "version-semver": "0.3.19", From 649dc3923e9411ddb642e3b5fb1f98548a008906 Mon Sep 17 00:00:00 2001 From: luncliff Date: Mon, 20 Jan 2025 21:58:28 +0900 Subject: [PATCH 6/8] [onnx] remove pybind11 feature --- ports/onnx/fix-cmakelists.patch | 58 ++------------------------------- ports/onnx/portfile.cmake | 33 ++++--------------- ports/onnx/vcpkg.json | 13 +------- 3 files changed, 10 insertions(+), 94 deletions(-) diff --git a/ports/onnx/fix-cmakelists.patch b/ports/onnx/fix-cmakelists.patch index b3f490096be2d9..2f5e79c95aff5a 100644 --- a/ports/onnx/fix-cmakelists.patch +++ b/ports/onnx/fix-cmakelists.patch @@ -2,7 +2,7 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt index b666eec..66c234d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -63,6 +63,27 @@ endif() +@@ -63,6 +63,16 @@ endif() include(GNUInstallDirs) @@ -15,22 +15,11 @@ index b666eec..66c234d 100644 + ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-operators-ml.proto3 + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnx +) -+# install python files -+if(BUILD_ONNX_PYTHON) -+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_data_pb.py -+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_data_pb2.py -+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_ml_pb2.py -+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_operators_ml_pb2.py -+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_operators_pb.py -+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_pb.py -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnx -+ ) -+endif() + set(ONNX_ROOT ${PROJECT_SOURCE_DIR}) # Read ONNX version -@@ -104,7 +125,8 @@ endif() +@@ -104,7 +114,8 @@ endif() # find_package Python has replaced PythonInterp and PythonLibs since cmake 3.12 # Use the following command in the future; now this is only compatible with the latest pybind11 # find_package(Python ${PY_VERSION} COMPONENTS Interpreter Development REQUIRED) @@ -40,46 +29,3 @@ index b666eec..66c234d 100644 if(BUILD_ONNX_PYTHON) find_package(PythonLibs ${PY_VERSION}) endif() -@@ -534,6 +556,7 @@ target_link_libraries(onnx PUBLIC onnx_proto) - add_onnx_global_defines(onnx) - - if(BUILD_ONNX_PYTHON) -+ find_package(Python3 ${PY_VERSION} COMPONENTS Development REQUIRED) - if("${PY_EXT_SUFFIX}" STREQUAL "") - if(MSVC) - set(PY_EXT_SUFFIX ".pyd") -@@ -542,7 +565,9 @@ if(BUILD_ONNX_PYTHON) - endif() - endif() - -- add_library(onnx_cpp2py_export MODULE "${ONNX_ROOT}/onnx/cpp2py_export.cc") -+ find_package(pybind11 2.2 CONFIG REQUIRED) -+ pybind11_add_module(onnx_cpp2py_export MODULE "${ONNX_ROOT}/onnx/cpp2py_export.cc") -+ install(TARGETS onnx_cpp2py_export DESTINATION ${CMAKE_INSTALL_LIBDIR}) - set_target_properties(onnx_cpp2py_export PROPERTIES PREFIX "") - set_target_properties(onnx_cpp2py_export - PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") -@@ -552,19 +577,10 @@ if(BUILD_ONNX_PYTHON) - target_include_directories(onnx_cpp2py_export PRIVATE - $ - $ -- $) -- -- # pybind11 is a header only lib -- find_package(pybind11 2.2 CONFIG) -- if(NOT pybind11_FOUND) -- if(EXISTS "${ONNX_ROOT}/third_party/pybind11/include/pybind11/pybind11.h") -- add_subdirectory("${ONNX_ROOT}/third_party/pybind11") -- else() -- message(FATAL_ERROR "cannot find pybind") -- endif() -- endif() -- -- target_include_directories(onnx_cpp2py_export PUBLIC -+ ${Python3_INCLUDE_DIRS}) -+ target_link_directories(onnx_cpp2py_export PRIVATE ${Python3_LIBRARY_DIRS}) -+ target_link_libraries(onnx_cpp2py_export PRIVATE ${Python3_LIBRARIES}) -+ target_include_directories(onnx_cpp2py_export PRIVATE - "${pybind11_INCLUDE_DIRS}" - "${PYTHON_INCLUDE_DIRS}") - diff --git a/ports/onnx/portfile.cmake b/ports/onnx/portfile.cmake index 75d8f7361f46b9..95514673e203c5 100644 --- a/ports/onnx/portfile.cmake +++ b/ports/onnx/portfile.cmake @@ -12,6 +12,9 @@ vcpkg_from_github( string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME) +# ONNX_CUSTOM_PROTOC_EXECUTABLE +find_program(PROTOC NAMES protoc PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf" REQUIRED NO_DEFAULT_PATH NO_CMAKE_PATH) + # ONNX_USE_PROTOBUF_SHARED_LIBS: find the library and check its file extension find_library(PROTOBUF_LIBPATH NAMES protobuf PATHS "${CURRENT_INSTALLED_DIR}/bin" "${CURRENT_INSTALLED_DIR}/lib" REQUIRED) get_filename_component(PROTOBUF_LIBNAME "${PROTOBUF_LIBPATH}" NAME) @@ -21,38 +24,16 @@ else() set(USE_PROTOBUF_SHARED OFF) endif() -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - pybind11 BUILD_ONNX_PYTHON -) - -# Like protoc, python is required for codegen. -if("pybind11" IN_LIST FEATURES) - x_vcpkg_get_python_packages(PYTHON_VERSION 3 OUT_PYTHON_VAR PYTHON3 - REQUIREMENTS_FILE "${SOURCE_PATH}/requirements-min.txt" - PACKAGES "pybind11" - ) - execute_process( - COMMAND "${PYTHON3}" -c "import site; print(site.getsitepackages()[0])" - OUTPUT_VARIABLE SITE_PACKAGES_DIR OUTPUT_STRIP_TRAILING_WHITESPACE - ) - find_path(pybind11_DIR NAMES pybind11Config.cmake PATHS "${SITE_PACKAGES_DIR}" "${SITE_PACKAGES_DIR}/Lib/site-packages" PATH_SUFFIXES "pybind11/share/cmake/pybind11" REQUIRED NO_DEFAULT_PATH) - list(APPEND FEATURE_OPTIONS "-Dpybind11_DIR:PATH=${pybind11_DIR}") -else() - vcpkg_find_acquire_program(PYTHON3) -endif() - -# PATH for .bat scripts so it can find 'python' -get_filename_component(PYTHON_DIR "${PYTHON3}" PATH) -vcpkg_add_to_path(PREPEND "${PYTHON_DIR}") +vcpkg_find_acquire_program(PYTHON3) vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS ${FEATURE_OPTIONS} - "-DPython3_EXECUTABLE=${PYTHON3}" + "-DPython3_EXECUTABLE:FILEPATH=${PYTHON3}" + "-DONNX_CUSTOM_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}" + "-DProtobuf_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}" -DONNX_ML=ON - -DONNX_GEN_PB_TYPE_STUBS=ON -DONNX_USE_PROTOBUF_SHARED_LIBS=${USE_PROTOBUF_SHARED} -DONNX_USE_LITE_PROTO=OFF -DONNX_USE_MSVC_STATIC_RUNTIME=${USE_STATIC_RUNTIME} diff --git a/ports/onnx/vcpkg.json b/ports/onnx/vcpkg.json index 3f1b022a4f17c0..30474e329a4787 100644 --- a/ports/onnx/vcpkg.json +++ b/ports/onnx/vcpkg.json @@ -19,16 +19,5 @@ "name": "vcpkg-cmake-config", "host": true } - ], - "features": { - "pybind11": { - "description": "Build Python binaries", - "dependencies": [ - { - "name": "vcpkg-get-python-packages", - "host": true - } - ] - } - } + ] } From c0293c971976d31626b822ff487357e34f13b2b0 Mon Sep 17 00:00:00 2001 From: luncliff Date: Mon, 20 Jan 2025 22:01:12 +0900 Subject: [PATCH 7/8] [onnx] update baseline --- versions/baseline.json | 2 +- versions/o-/onnx.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index fff73d73e9f749..3ea67f5e4f90ab 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6606,7 +6606,7 @@ }, "onnx": { "baseline": "1.17.0", - "port-version": 0 + "port-version": 1 }, "onnx-optimizer": { "baseline": "0.3.19", diff --git a/versions/o-/onnx.json b/versions/o-/onnx.json index b3a1b486919351..48edbd4ddcbec6 100644 --- a/versions/o-/onnx.json +++ b/versions/o-/onnx.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "1ae91479c59de528eae6e6db5235b8ff0460e222", + "version-semver": "1.17.0", + "port-version": 1 + }, { "git-tree": "9849fadc0639a430cf9c49434b60cbeb08989112", "version-semver": "1.17.0", From 311aa985303e2b2e410a2903a7fee62f77bebdd4 Mon Sep 17 00:00:00 2001 From: luncliff Date: Tue, 21 Jan 2025 22:48:57 +0900 Subject: [PATCH 8/8] remove wrong change --- vcpkg-registry | 1 - 1 file changed, 1 deletion(-) delete mode 160000 vcpkg-registry diff --git a/vcpkg-registry b/vcpkg-registry deleted file mode 160000 index 02a0a60c0db67a..00000000000000 --- a/vcpkg-registry +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 02a0a60c0db67a68f603b5d26f60d3281c1f5ecf