0

I have a project that already uses SDL2, sdl_image and sdl_ttf, I want to add sdl_mixer to it. My conanfile.py looks like this:

from conan import ConanFile

class CompressorRecipe(ConanFile):
    settings = "os", "compiler", "build_type", "arch"
    generators = "CMakeToolchain", "CMakeDeps"

    def build_requirements(self):
        self.tool_requires("cmake/3.27.0")

    def requirements(self):
        self.requires("sdl_image/2.0.5")
        self.requires("sdl_ttf/2.20.1")
        #self.requires("sdl_mixer/2.0.4")
        self.requires("libpng/1.6.40", override=True)
        self.requires("sdl/2.26.5", override=True)

I'm installing dependencies with this command:

conan install . --output-folder=build --build=missing --profile=Debug

It runs successfully, but when I'm trying to add sdl_mixer from commented line, it returns this error:

ERROR: Package 'sdl_mixer/2.0.4' not resolved: sdl_mixer/2.0.4: Cannot load recipe.
Error loading conanfile at 'C:\Users\username\.conan2\p\sdl_m16f68a6f39148\e\conanfile.py': Unable to load conanfile in C:\Users\username\.conan2\p\sdl_m16f68a6f39148\e\conanfile.py
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\username\.conan2\p\sdl_m16f68a6f39148\e\conanfile.py", line 1, in <module>
    from conans import CMake, tools
ImportError: cannot import name 'CMake'

I've already installed cmake for python:

C:\Users\username>python -m pip install CMake
Requirement already satisfied: CMake in c:\python311\lib\site-packages (3.27.0)

And I can't import cmake from conanfile, if I change first line to from conan import ConanFile, CMake, it returns the same ImportError: cannot import name 'CMake' error at the first line

Also, I have already installed conan with pip with python -m pip install conan. How can I fix this issue?

SavedowW
  • 39
  • 5

1 Answers1

0

Your error is not about missing cmake but in python/conan recipe.

Error says:

from conans import CMake, tools
ImportError: cannot import name 'CMake'

If you check out the page: https://docs.conan.io/1/migrating_to_2.0/recipes.html -- it lists that conans imports should be migrated to new packages when moving to >= conan 2.0

eg. Your recipe is intended for pre 2.0 conan but your conan installation is probably already 2.0 or greater.

Downgrade your conan or re-install existing packages with the new conan (if those packages have been upgraded to Conan 2.0)

rasjani
  • 7,372
  • 4
  • 22
  • 35
  • 1
    ``sdl_mixer`` recipe in ConanCenter hasn't been updated to 2.0 yet: https://github.com/conan-io/conan-center-index/blob/master/recipes/sdl_mixer/all/conanfile.py. PR for it is on its way: https://github.com/conan-io/conan-center-index/pull/18836 – drodri Jul 24 '23 at 08:58