Skip to content

Commit

Permalink
CompatAPI: Change Conan API access
Browse files Browse the repository at this point in the history
  • Loading branch information
Croydon committed Mar 7, 2023
1 parent 3436c11 commit d86d05b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions bincrafters_conventions/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ class CompatConanAPI():
def __init__(self):
try:
from conan import conan_version as client_version
from conan.api.conan_api import ConanAPI as conan_api
from conan.api.conan_api import ConanAPI as conan_api_v2
conan_api = conan_api_v2()
except:
from conans import __version__ as client_version
from conans.client import conan_api
from conans.client import conan_api as conan_api_v1
conan_api = conan_api_v1.Conan.factory()

from conan.tools.scm import Version

Expand Down
3 changes: 1 addition & 2 deletions bincrafters_conventions/compat/subapi/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ def compat_inspect_attribute(self, conanfile: str, attribute: str):
print(conanfile_class)
print(f"higher than 2.0 value: {conanfile_class}")
else:
conan_instance, _, _ = self.compat_api.ConanAPI.Conan.factory()
value = conan_instance.inspect(path=conanfile, attributes=[attribute])[attribute]
value = self.compat_api.ConanAPI.inspect(path=conanfile, attributes=[attribute])[attribute]
print(f"lower than 2.0 value: {value}")

return value

0 comments on commit d86d05b

Please sign in to comment.