Closed anurag-quantum closed 2 weeks ago
Hi @anurag-quantum
Thanks for your feedback.
This wouldn't be a bug. You are using with Conan 2.X a legacy Conan 1.X recipe, that contains from conan import ConanFile, CMake, tools
, which no longer exist in Conan 2. It seems you replaced the from conans
with from conan
, but that is not enough, you need to use the new imports and tools, it is not just that the import changes, but the legacy tools were replaced already in Conan 1.X many years ago with modern alternatives, that can be imported from the namespaces like from conan.tools.cmake import CMakeDeps, CMakeToolchain, CMake, cmake_layout
.
Please have a look to https://docs.conan.io/1/conan_v2.html, the very first section talks about the imports.
@memsharded Thanks. Thats resolved my issue.
Great, closing the ticket as solved then, thanks for the feedback
After making the change, I am facing this .
ERROR: Conanfile not found at /Users/anuragpateriya/Desktop/qiskit_repo/qe-compiler/conanfile.txt
while running this command.
ERROR: Error loading conanfile at '/Users/anuragpateriya/Desktop/qiskit_repo/qe-compiler/qe-compiler/conanfile.py': Unable to load conanfile in /Users/anuragpateriya/Desktop/qiskit_repo/qe-compiler/qe-compiler/conanfile.py
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 1022, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/Users/anuragpateriya/Desktop/qiskit_repo/qe-compiler/qe-compiler/conanfile.py", line 14, in <module>
from conans import ConanFile, CMake, tools
ImportError: cannot import name 'ConanFile' from 'conans' (/usr/local/Cellar/conan/2.9.2/libexec/lib/python3.13/site-packages/conans/__init__.py)
anuragpateriya@anurags-MBP build % cd ..
anuragpateriya@anurags-MBP qe-compiler % nano conanfile.py
anuragpateriya@anurags-MBP qe-compiler % conan install .. --build=outdated -pr:h default -pr:b default
ERROR: Conanfile not found at /Users/anuragpateriya/Desktop/qiskit_repo/qe-compiler/conanfile.txt
from conans import ConanFile, CMake, tools
You are still importing from conans
which doesn't exist in Conan 2. You have 2 options:
from conan.tools.cmake import CMakeDeps
and change the rest of the recipe acordingly, as described in the migration guide (by the way these changes should also work in Conan 1.X, they have been available for years in Conan 1.X, and it is possible to have recipes that work simultaneously in Conan 1 and Conan 2apologies for posting incorrect logs. Please check these logs.
anuragpateriya@anurags-MBP qe-compiler % nano conanfile.py <<------- here i changed the conanfile.
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
import os
from conan.tools.cmake import CMakeDeps, CMakeToolchain, CMake, cmake_layout
anuragpateriya@anurags-MBP qe-compiler % conan install .. --build=outdated -pr:h default -pr:b default ERROR: Conanfile not found at /Users/anuragpateriya/Desktop/qiskit_repo/qe-compiler/conanfile.txt anuragpateriya@anurags-MBP qe-compiler % conan install . --output-folder=build
======== Input profiles ========
Profile host:
[settings]
arch=armv8
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=15
os=Macos
Profile build:
[settings]
arch=armv8
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=15
os=Macos
ERROR: Error loading conanfile at '/Users/anuragpateriya/Desktop/qiskit_repo/qe-compiler/qe-compiler/conanfile.py': Unable to load conanfile in /Users/anuragpateriya/Desktop/qiskit_repo/qe-compiler/qe-compiler/conanfile.py
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 1022, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/Users/anuragpateriya/Desktop/qiskit_repo/qe-compiler/qe-compiler/conanfile.py", line 25, in <module>
class QSSCompilerConan(ConanFile):
^^^^^^^^^
NameError: name 'ConanFile' is not defined
NameError: name 'ConanFile' is not defined
You still need the from conan import ConanFile
Describe the bug
MacOS, virtual environment
How to reproduce it
No response