Skip to content

Commit

Permalink
Merge branch 'release/0.28.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Jun 4, 2019
2 parents 2f043fc + ff4abbd commit 1b30b47
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 24 deletions.
11 changes: 9 additions & 2 deletions cpt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

__version__ = '0.27.0'
NEWEST_CONAN_SUPPORTED = "1.16.0-dev"
__version__ = '0.28.0'
NEWEST_CONAN_SUPPORTED = "1.17.0-dev"


def get_client_version():
from conans.model.version import Version
from conans import __version__ as client_version
# It is a mess comparing dev versions, lets assume that the -dev is the further release
return Version(client_version.replace("-dev", ""))
17 changes: 13 additions & 4 deletions cpt/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from collections import defaultdict

import six
from conans import __version__ as client_version, tools
from conans import tools
from conans.client.conan_api import Conan
from conans.client.runner import ConanRunner
from conans.model.ref import ConanFileReference
from conans.model.version import Version

from cpt import NEWEST_CONAN_SUPPORTED
from cpt import NEWEST_CONAN_SUPPORTED, get_client_version
from cpt.auth import AuthManager
from cpt.builds_generator import BuildConf, BuildGenerator
from cpt.ci_manager import CIManager
Expand All @@ -25,10 +25,17 @@


def load_cf_class(path, conan_api):
client_version = get_client_version()
if Version(client_version) < Version("1.7.0"):
from conans.client.loader_parse import load_conanfile_class
return load_conanfile_class(path)
elif Version(client_version) < Version("1.16.0"):
remotes = conan_api._cache.registry.load_remotes()
conan_api.python_requires.enable_remotes(remotes=remotes)
return conan_api._loader.load_class(path)
else:
remotes = conan_api._cache.registry.load_remotes()
conan_api._python_requires.enable_remotes(remotes=remotes)
return conan_api._loader.load_class(path)


Expand Down Expand Up @@ -109,6 +116,8 @@ def __init__(self, username=None, channel=None, runner=None,
upload_dependencies=None,
force_selinux=None):

conan_version = get_client_version()

self.printer = Printer(out)
self.printer.print_rule()
self.printer.print_ascci_art()
Expand Down Expand Up @@ -283,7 +292,7 @@ def __init__(self, username=None, channel=None, runner=None,
self.curpage = curpage or os.getenv("CONAN_CURRENT_PAGE", 1)
self.total_pages = total_pages or os.getenv("CONAN_TOTAL_PAGES", 1)

self.conan_pip_package = os.getenv("CONAN_PIP_PACKAGE", "conan==%s" % client_version)
self.conan_pip_package = os.getenv("CONAN_PIP_PACKAGE", "conan==%s" % conan_version)
if self.conan_pip_package in ("0", "False"):
self.conan_pip_package = ""
self.vs10_x86_64_enabled = vs10_x86_64_enabled
Expand All @@ -304,7 +313,7 @@ def valid_pair(var, value):
if valid_pair(var, value)})

self._newest_supported_conan_version = Version(NEWEST_CONAN_SUPPORTED).minor(fill=False)
self._client_conan_version = client_version
self._client_conan_version = conan_version

def _check_conan_version(self):
tmp = self._newest_supported_conan_version
Expand Down
6 changes: 4 additions & 2 deletions cpt/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from conans.client.profile_loader import _load_profile
from conans.model.version import Version
from conans.util.files import save
from conans import __version__ as conan_version
from cpt import get_client_version


def get_profiles(client_cache, build_config, base_profile_name=None):

Expand Down Expand Up @@ -53,7 +54,8 @@ def patch_default_base_profile(conan_api, profile_abs_path):
is other, we have to change the include"""
text = tools.load(profile_abs_path)
if "include(default)" in text: # User didn't specified a custom profile
if Version(conan_version) < Version("1.12.0"):
conan_version = get_client_version()
if conan_version < Version("1.12.0"):
cache = conan_api._client_cache
else:
cache = conan_api._cache
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.16.0
conan>=1.7.0, <1.17.0
tabulate==0.8.2
8 changes: 5 additions & 3 deletions cpt/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import subprocess
from collections import namedtuple

from conans import tools, __version__ as client_version
from conans import tools
from conans.model.version import Version
from conans.model.ref import ConanFileReference

from cpt import __version__ as package_tools_version
from cpt import __version__ as package_tools_version, get_client_version
from cpt.config import ConfigManager
from cpt.printer import Printer
from cpt.profiles import load_profile, patch_default_base_profile
Expand Down Expand Up @@ -42,8 +42,9 @@ def __init__(self, profile_abs_path, reference, conan_api, uploader,
self._upload_dependencies = self._upload_dependencies or []

patch_default_base_profile(conan_api, profile_abs_path)
client_version = get_client_version()

if Version(client_version) < Version("1.12.0"):
if client_version < Version("1.12.0"):
cache = self._conan_api._client_cache
else:
cache = self._conan_api._cache
Expand All @@ -55,6 +56,7 @@ def settings(self):
return self._profile.settings

def run(self):
client_version = get_client_version()

if self._config_url:
ConfigManager(self._conan_api, self.printer).install(url=self._config_url)
Expand Down
1 change: 0 additions & 1 deletion cpt/test/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def setUp(self):
os.environ.update({"CONAN_USER_HOME": self.conan_home, "CONAN_PIP_PACKAGE": "0"})
self.output = TestBufferConanOutput()
self.api, self.client_cache, _ = ConanAPIV1.factory()
print("Testing with Conan Folder=%s" % self.client_cache.conan_folder)

def tearDown(self):
os.chdir(self.old_folder)
Expand Down
3 changes: 2 additions & 1 deletion cpt/test/integration/docker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import unittest
import time

from conans import __version__ as client_version
from conans import tools
from conans.model.ref import ConanFileReference
from conans.model.version import Version
from cpt import get_client_version
from cpt.packager import ConanMultiPackager
from cpt.test.integration.base import BaseTest, CONAN_UPLOAD_PASSWORD, CONAN_LOGIN_UPLOAD
from cpt.test.unit.utils import MockCIManager
Expand All @@ -30,6 +30,7 @@ def tearDown(self):

@unittest.skipUnless(is_linux_and_have_docker(), "Requires Linux and Docker")
def test_docker(self):
client_version = get_client_version()
ci_manager = MockCIManager()
unique_ref = "zlib/%s" % str(time.time())
conanfile = """from conans import ConanFile
Expand Down
7 changes: 3 additions & 4 deletions cpt/test/test_client/tools.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import six
from conans import __version__ as client_version
from conans import __version__ as conan_version
from conans.client.conan_api import Conan
from conans.model.version import Version
from cpt import get_client_version

from cpt.packager import ConanMultiPackager


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"):
extra_init_kwargs.update({'requester': tc.requester})

if Version(conan_version) < Version("1.12.0"):
if Version(client_version) < Version("1.12.0"):
cache = tc.client_cache
else:
cache = tc.cache
Expand Down
3 changes: 2 additions & 1 deletion cpt/test/unit/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os
from collections import namedtuple

from conans import __version__ as conan_version
from conans import tools
from conans.model.ref import ConanFileReference
from conans.test.utils.test_files import temp_folder
from conans.util.files import save
from conans.model.version import Version
from cpt import get_client_version


class MockRunner(object):
Expand Down Expand Up @@ -85,6 +85,7 @@ def get_profile_from_call(self, call):
if call.name != "create":
raise Exception("Invalid test, not contains a create: %s" % self.calls)
from conans.client.profile_loader import read_profile
conan_version = get_client_version()
if Version(conan_version) < Version("1.12.0"):
profile_name = call.kwargs["profile_name"]
else:
Expand Down
15 changes: 10 additions & 5 deletions cpt/uploader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from conans.model.version import Version

from cpt import get_client_version


class Uploader(object):

def __init__(self, conan_api, remote_manager, auth_manager, printer, upload_retry):
Expand All @@ -16,6 +21,7 @@ def upload_packages(self, reference, upload, package_id):
self._upload_artifacts(reference, upload, package_id)

def _upload_artifacts(self, reference, upload, package_id=None):
client_version = get_client_version()
remote_name = self.remote_manager.upload_remote_name
if not remote_name:
self.printer.print_message("Upload skipped, not upload remote available")
Expand All @@ -25,24 +31,23 @@ def _upload_artifacts(self, reference, upload, package_id=None):
return

if upload:
from conans.model.version import Version
from conans import __version__ as client_version

self.printer.print_message("Uploading packages for '%s'" % str(reference))
self.auth_manager.login(remote_name)

if Version(client_version) < Version("1.7.0"):
if client_version < Version("1.7.0"):
self.conan_api.upload(str(reference),
package=package_id,
remote=remote_name,
force=True,
retry=int(self._upload_retry))
elif Version(client_version) < Version("1.8.0"):
elif client_version < Version("1.8.0"):
self.conan_api.upload(str(reference),
package=package_id,
remote_name=remote_name,
force=True,
retry=int(self._upload_retry))
elif Version(client_version) < Version("1.16.0"):
elif client_version < Version("1.17.0"):
all_packages = package_id != None
self.conan_api.upload(str(reference),
all_packages=all_packages,
Expand Down

0 comments on commit 1b30b47

Please sign in to comment.