I have the following conanfile.py
in my project on which I run the command conan install . --output-folder=build --build=missing -v
.
import os
from conan import ConanFile
class ProjectRecipe(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"
def requirements(self):
self.requires("armadillo/12.6.4")
self.requires("openssl/3.3.1")
self.requires("onnxruntime/1.18.1")
self.requires("boost/1.86.0", force=True)
The command completes successfully. Below is the latter part of the output:
======== Installing packages ========
abseil/20240116.1: Already installed! (1 of 15)
bzip2/1.0.8: Already installed! (2 of 15)
cpuinfo/cci.20231129: Already installed! (3 of 15)
flatbuffers/23.5.26: Already installed! (4 of 15)
openblas/0.3.25: Already installed! (5 of 15)
zlib/1.3.1: Already installed! (6 of 15)
armadillo/12.6.4: Already installed! (7 of 15)
boost/1.86.0: Already installed! (8 of 15)
boost/1.86.0: Disabled magic autolinking (smart and magic decisions)
protobuf/3.21.12: Already installed! (9 of 15)
re2/20231101: Already installed! (10 of 15)
openssl/3.3.1: Already installed! (11 of 15)
onnx/1.16.2: Already installed! (12 of 15)
libcurl/8.10.1: Already installed! (13 of 15)
date/3.0.1: Already installed! (14 of 15)
onnxruntime/1.18.1: Already installed! (15 of 15)
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated: 'cpp_info.names' used in: libcurl/8.10.1, flatbuffers/23.5.26, openblas/0.3.25, zlib/1.3.1, onnx/1.16.2, openssl/3.3.1, protobuf/3.21.12, abseil/20240116.1, boost/1.86.0, armadillo/12.6.4, bzip2/1.0.8
WARN: deprecated: 'cpp_info.build_modules' used in: flatbuffers/23.5.26, onnx/1.16.2, openssl/3.3.1, protobuf/3.21.12, abseil/20240116.1, armadillo/12.6.4, bzip2/1.0.8
WARN: deprecated: 'env_info' used in: flatbuffers/23.5.26, openblas/0.3.25, openssl/3.3.1, protobuf/3.21.12, boost/1.86.0, bzip2/1.0.8
WARN: deprecated: 'cpp_info.filenames' used in: flatbuffers/23.5.26, protobuf/3.21.12, boost/1.86.0
WARN: deprecated: 'user_info' used in: boost/1.86.0
======== Finalizing install (deploy, generators) ========
conanfile.py: Writing generators to C:\Users\YawManu\source\repos\CMakeProject1\build
conanfile.py: Generator 'CMakeToolchain' calling 'generate()'
conanfile.py: CMakeToolchain generated: conan_toolchain.cmake
conanfile.py: CMakeToolchain: Preset 'conan-default' added to CMakePresets.json.
(cmake>=3.23) cmake --preset conan-default
(cmake<3.23) cmake <path> -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW
conanfile.py: CMakeToolchain generated: C:\Users\YawManu\source\repos\CMakeProject1\build\CMakePresets.json
conanfile.py: CMakeToolchain generated: C:\Users\YawManu\source\repos\CMakeProject1\CMakeUserPresets.json
conanfile.py: Generator 'CMakeDeps' calling 'generate()'
conanfile.py: CMakeDeps necessary find_package() and targets for your CMakeLists.txt
find_package(Armadillo)
find_package(onnxruntime)
find_package(OpenSSL)
find_package(Boost)
target_link_libraries(... Armadillo::Armadillo onnxruntime::onnxruntime openssl::openssl boost::boost)
conanfile.py: Generating aggregated env files
conanfile.py: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
Install finished successfully
Yet the CMake generation in Visual Studio fails with the output (latter part):
1> [CMake] [DEBUG:VsDevCmd.bat] --------------------- VS Developer Command Prompt Environment [post-init] ---------------------
1> [CMake] [vcvarsall.bat] Environment initialized for: 'x64'
1> [CMake] [1/64] Running gen_proto.py on onnx/onnx.in.proto
1> [CMake] FAILED: onnx/onnx-ml.proto C:/Users/YawManu/.conan2/p/b/onnxeaf435b38615b/b/build/Debug/onnx/onnx-ml.proto
1> [CMake] C:\WINDOWS\system32\cmd.exe /C "cd /D C:\Users\YawManu\.conan2\p\b\onnxeaf435b38615b\b\build\Debug && "C:\Program Files\Conan\conan\conan.exe" C:/Users/YawManu/.conan2/p/b/onnxeaf435b38615b/b/src/onnx/gen_proto.py -p onnx -o C:/Users/YawManu/.conan2/p/b/onnxeaf435b38615b/b/build/Debug/onnx onnx -m --protoc_path C:/Users/YawManu/.conan2/p/proto8625022988b17/p/bin/protoc.exe"
1> [CMake] 'C:/Users/YawManu/.conan2/p/b/onnxeaf435b38615b/b/src/onnx/gen_proto.py' is not a Conan command. See 'conan --help'.
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake] ERROR: Unknown command 'C:/Users/YawManu/.conan2/p/b/onnxeaf435b38615b/b/src/onnx/gen_proto.py'
1> [CMake]
1> [CMake] ninja: build stopped: subcommand failed.
1> [CMake]
1> [CMake] onnx/1.16.2: ERROR:
1> [CMake] Package '6a7a6783386189c6725e6d4d255e7cdc4e450d20' build failed
1> [CMake] onnx/1.16.2: WARN: Build folder C:\Users\YawManu\.conan2\p\b\onnxeaf435b38615b\b\build\Debug
1> [CMake] ERROR: onnx/1.16.2: Error in build() method, line 136
1> [CMake] cmake.build()
1> [CMake] ConanException: Error 1 while executing
1> [CMake] CMake Error at cmake-conan/conan_provider.cmake:483 (message):
1> [CMake] Conan install failed='1'
1> [CMake] Call Stack (most recent call first):
1> [CMake] cmake-conan/conan_provider.cmake:591 (conan_install)
1> [CMake] CMakeLists.txt:14 (find_package)
1> [CMake] -- Configuring incomplete, errors occurred!
1> 'C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_C_COMPILER:STRING="cl.exe" -DCMAKE_CXX_COMPILER:STRING="cl.exe" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:/Users/YawManu/source/repos/CMakeProject1/out/install/x64-debug" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\YawManu\source\repos\CMakeProject1" 2>&1"' execution failed with error: ''C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_C_COMPILER:STRING="cl.exe" -DCMAKE_CXX_COMPILER:STRING="cl.exe" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:/Users/YawManu/source/repos/CMakeProject1/out/install/x64-debug" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\YawManu\source\repos\CMakeProject1" 2>&1"' returned with exit code: 1'.
What could be wrong? Thank you in advance for helping.
EDIT: Below is the rule of the ninja file which causes the error.
#############################################
# Custom command for onnx\onnx-ml.proto
build onnx\onnx-ml.proto | ${cmake_ninja_workdir}onnx\onnx-ml.proto: CUSTOM_COMMAND C$:\Users\YawManu\.conan2\p\b\onnxeaf435b38615b\b\src\onnx\onnx.in.proto
COMMAND = C:\WINDOWS\system32\cmd.exe /C "cd /D C:\Users\YawManu\.conan2\p\b\onnxeaf435b38615b\b\build\Debug && "C:\Program Files\Conan\conan\conan.exe" C:/Users/YawManu/.conan2/p/b/onnxeaf435b38615b/b/src/onnx/gen_proto.py -p onnx -o C:/Users/YawManu/.conan2/p/b/onnxeaf435b38615b/b/build/Debug/onnx onnx -m --protoc_path C:/Users/YawManu/.conan2/p/proto8625022988b17/p/bin/protoc.exe"
DESC = Running gen_proto.py on onnx/onnx.in.proto
restat = 1
The root cause is that the Conan recipe for onnx sets the PYTHON_EXECUTABLE
variable to sys.executable
. Normally this is the Python program used to invoke Conan, but in your case it is a conan.exe, which is not a Python interpreter.
This was reported upstream as issue #22636 and #21790.
The quick and dirty solution is to patch the conanfile.py of onnx, as stated in this comment:
After I modify conanfile.py using line
tc.variables["PYTHON_EXECUTABLE"] = "python"
, it works now.
You will need a standalone Python installation for this to work, of course.