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:UsersYawManusourcereposCMakeProject1build
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:UsersYawManusourcereposCMakeProject1buildCMakePresets.json
conanfile.py: CMakeToolchain generated: C:UsersYawManusourcereposCMakeProject1CMakeUserPresets.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:WINDOWSsystem32cmd.exe /C "cd /D C:UsersYawManu.conan2pbonnxeaf435b38615bbbuildDebug && "C:Program FilesConanconanconan.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:UsersYawManu.conan2pbonnxeaf435b38615bbbuildDebug
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:WINDOWSsystem32cmd.exe' '/c "%SYSTEMROOT%System32chcp.com 65001 >NUL && "C:PROGRAM FILESMICROSOFT VISUAL STUDIO2022COMMUNITYCOMMON7IDECOMMONEXTENSIONSMICROSOFTCMAKECMakebincmake.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 FILESMICROSOFT VISUAL STUDIO2022COMMUNITYCOMMON7IDECOMMONEXTENSIONSMICROSOFTCMAKENinjaninja.exe" "C:UsersYawManusourcereposCMakeProject1" 2>&1"' execution failed with error: ''C:WINDOWSsystem32cmd.exe' '/c "%SYSTEMROOT%System32chcp.com 65001 >NUL && "C:PROGRAM FILESMICROSOFT VISUAL STUDIO2022COMMUNITYCOMMON7IDECOMMONEXTENSIONSMICROSOFTCMAKECMakebincmake.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 FILESMICROSOFT VISUAL STUDIO2022COMMUNITYCOMMON7IDECOMMONEXTENSIONSMICROSOFTCMAKENinjaninja.exe" "C:UsersYawManusourcereposCMakeProject1" 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 onnxonnx-ml.proto
build onnxonnx-ml.proto | ${cmake_ninja_workdir}onnxonnx-ml.proto: CUSTOM_COMMAND C$:UsersYawManu.conan2pbonnxeaf435b38615bbsrconnxonnx.in.proto
COMMAND = C:WINDOWSsystem32cmd.exe /C "cd /D C:UsersYawManu.conan2pbonnxeaf435b38615bbbuildDebug && "C:Program FilesConanconanconan.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
2
Answers
It turns out removing the conan installation done with the Windows installer and reinstalling conan with
pip
fixes the problem. Be sure to clear the caches. That's a pitfallThe root cause is that the Conan recipe for onnx sets the
PYTHON_EXECUTABLE
variable tosys.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:
You will need a standalone Python installation for this to work, of course.