Skip to content

Commit

Permalink
Merge branch 'release/0.29.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Jul 30, 2019
2 parents 2b5a969 + 3ff8a46 commit 9041688
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 15 deletions.
4 changes: 2 additions & 2 deletions cpt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

__version__ = '0.29.0'
NEWEST_CONAN_SUPPORTED = "1.18.0-dev"
__version__ = '0.29.1'
NEWEST_CONAN_SUPPORTED = "1.19.0-dev"


def get_client_version():
Expand Down
12 changes: 10 additions & 2 deletions cpt/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ def load_cf_class(path, conan_api):
remotes = conan_api._cache.registry.load_remotes()
conan_api.python_requires.enable_remotes(remotes=remotes)
return conan_api._loader.load_class(path)
else:
elif Version(client_version) < Version("1.18.0"):
remotes = conan_api._cache.registry.load_remotes()
conan_api._python_requires.enable_remotes(remotes=remotes)
return conan_api._loader.load_class(path)
else:
if not conan_api.app:
conan_api.create_app()
remotes = conan_api.app.cache.registry.load_remotes()
conan_api.app.python_requires.enable_remotes(remotes=remotes)
return conan_api.app.loader.load_class(path)


class PlatformInfo(object):
Expand Down Expand Up @@ -132,7 +138,9 @@ def __init__(self, username=None, channel=None, runner=None,
self.cwd = cwd or os.getcwd()

if not conan_api:
self.conan_api, self.client_cache, _ = Conan.factory()
self.conan_api, _, _ = Conan.factory()
self.conan_api.create_app()
self.client_cache = self.conan_api.app.cache
else:
self.conan_api = conan_api
self.client_cache = client_cache
Expand Down
6 changes: 5 additions & 1 deletion cpt/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ def patch_default_base_profile(conan_api, profile_abs_path):
conan_version = get_client_version()
if conan_version < Version("1.12.0"):
cache = conan_api._client_cache
else:
elif conan_version < Version("1.18.0"):
cache = conan_api._cache
else:
if not conan_api.app:
conan_api.create_app()
cache = conan_api.app.cache

default_profile_name = os.path.basename(cache.default_profile_path)
if not os.path.exists(cache.default_profile_path):
Expand Down
2 changes: 1 addition & 1 deletion cpt/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
six>=1.10.0
conan>=1.7.0, <1.18.0
conan>=1.7.0, <1.19.0
tabulate==0.8.2
6 changes: 5 additions & 1 deletion cpt/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ def __init__(self, profile_abs_path, reference, conan_api, uploader,

if client_version < Version("1.12.0"):
cache = self._conan_api._client_cache
else:
elif client_version < Version("1.18.0"):
cache = self._conan_api._cache
else:
if not conan_api.app:
conan_api.create_app()
cache = conan_api.app.cache

self._profile = load_profile(profile_abs_path, cache)

Expand Down
4 changes: 3 additions & 1 deletion cpt/test/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def setUp(self):
self.old_env = dict(os.environ)
os.environ.update({"CONAN_USER_HOME": self.conan_home, "CONAN_PIP_PACKAGE": "0"})
self.output = TestBufferConanOutput()
self.api, self.client_cache, _ = ConanAPIV1.factory()
self.api, _, _ = ConanAPIV1.factory()
self.api.create_app()
self.client_cache = self.api.app.cache

def tearDown(self):
os.chdir(self.old_folder)
Expand Down
10 changes: 5 additions & 5 deletions cpt/test/test_client/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@


def get_patched_multipackager(tc, *args, **kwargs):
tc.init_dynamic_vars()
client_version = get_client_version()
extra_init_kwargs = {}
if Version(client_version) >= Version("1.11"):
if Version("1.11") < Version(client_version) < Version("1.18"):
extra_init_kwargs.update({'requester': tc.requester})
elif Version(client_version) >= Version("1.18"):
extra_init_kwargs.update({'http_requester': tc.requester})

if Version(client_version) < Version("1.12.0"):
cache = tc.client_cache
else:
cache = tc.cache

conan_api = Conan(cache, tc.user_io, tc.runner, tc.remote_manager, tc.hook_manager,
interactive=False, **extra_init_kwargs)
conan_api = Conan(cache_folder=cache.cache_folder, output=tc.out, **extra_init_kwargs)

class Printer(object):

Expand All @@ -29,7 +29,7 @@ def __init__(self, tc):
def __call__(self, contents):
if six.PY2:
contents = unicode(contents)
self.tc.user_io.out._buffer.write(contents)
self.tc.out.write(contents)

kwargs["out"] = Printer(tc)
kwargs["conan_api"] = conan_api
Expand Down
5 changes: 4 additions & 1 deletion cpt/test/unit/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
from collections import namedtuple

import mock

from conans import tools
from conans.model.ref import ConanFileReference
from conans.test.utils.test_files import temp_folder
Expand Down Expand Up @@ -32,12 +34,13 @@ def __init__(self, *args, **kwargs):

Action = namedtuple("Action", "name args kwargs")


class MockConanAPI(object):

def __init__(self):
self.calls = []
self._client_cache = self._cache = MockConanCache()
self.app = mock.Mock()
self.app.cache = self._client_cache

def create(self, *args, **kwargs):
reference = ConanFileReference(kwargs["name"], kwargs["version"], kwargs["user"], kwargs["channel"])
Expand Down
2 changes: 1 addition & 1 deletion cpt/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _upload_artifacts(self, reference, upload, package_id=None):
remote_name=remote_name,
force=True,
retry=int(self._upload_retry))
elif client_version < Version("1.18.0"):
elif client_version <= Version("1.19.0"):
all_packages = package_id != None
self.conan_api.upload(str(reference),
all_packages=all_packages,
Expand Down

0 comments on commit 9041688

Please sign in to comment.