From 441c411f262410b2221da168987173f90e0c81c0 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 15 Jan 2019 19:23:47 -0200 Subject: [PATCH 1/5] #506 Fix remote address format Signed-off-by: Uilian Ries --- bincrafters/__init__.py | 2 +- bincrafters/build_shared.py | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bincrafters/__init__.py b/bincrafters/__init__.py index 98e595c..f7d1e3e 100644 --- a/bincrafters/__init__.py +++ b/bincrafters/__init__.py @@ -1 +1 @@ -__version__ = '0.17.6' +__version__ = '0.17.7' diff --git a/bincrafters/build_shared.py b/bincrafters/build_shared.py index e654593..64a3890 100644 --- a/bincrafters/build_shared.py +++ b/bincrafters/build_shared.py @@ -4,6 +4,7 @@ import os import re import platform +from six import string_types from cpt.packager import ConanMultiPackager from cpt.tools import split_colon_env @@ -102,18 +103,22 @@ def get_user_repository(username, repository_name): def get_conan_upload(username): repository_name = os.getenv("BINTRAY_REPOSITORY", "public-conan") - return os.getenv("CONAN_UPLOAD", get_user_repository(username, repository_name)) + return os.getenv("CONAN_UPLOAD", get_user_repository(username, repository_name)).split('@') def get_conan_remotes(username): - # While redundant, this moves upload remote to position 0. - remotes = [get_conan_upload(username)] - - # Add bincrafters repository for other users, e.g. if the package would - # require other packages from the bincrafters repo. - bincrafters_user = "bincrafters" - if username != bincrafters_user: - remotes.append(get_conan_upload(bincrafters_user)) + remotes = os.getenv("CONAN_REMOTES") + if not remotes: + # While redundant, this moves upload remote to position 0. + remotes = [get_conan_upload(username)] + + # Add bincrafters repository for other users, e.g. if the package would + # require other packages from the bincrafters repo. + bincrafters_user = "bincrafters" + if username != bincrafters_user: + remotes.append(get_conan_upload(bincrafters_user)) + if isinstance(remotes, string_types): + remotes.split('@') return remotes @@ -136,7 +141,7 @@ def get_builder(build_policy=None): username, channel, version, login_username = get_conan_vars() reference = "{0}/{1}".format(name, version) upload = get_conan_upload(username) - remotes = os.getenv("CONAN_REMOTES", get_conan_remotes(username)) + remotes = get_conan_remotes(username) upload_when_stable = get_upload_when_stable() stable_branch_pattern = os.getenv("CONAN_STABLE_BRANCH_PATTERN", "stable/*") archs = get_archs() From 4b492a993d8745c5f4effc73fe34f230bf870b1c Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 15 Jan 2019 19:26:00 -0200 Subject: [PATCH 2/5] #506 fix remote url --- bincrafters/build_shared.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bincrafters/build_shared.py b/bincrafters/build_shared.py index 64a3890..f197476 100644 --- a/bincrafters/build_shared.py +++ b/bincrafters/build_shared.py @@ -118,7 +118,7 @@ def get_conan_remotes(username): if username != bincrafters_user: remotes.append(get_conan_upload(bincrafters_user)) if isinstance(remotes, string_types): - remotes.split('@') + remotes = remotes.split('@') return remotes From e6e66025d7e7a34123f19b00863f890263c629fe Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 15 Jan 2019 22:24:17 -0200 Subject: [PATCH 3/5] Fix remote url format Signed-off-by: Uilian Ries --- bincrafters/build_shared.py | 27 +++++++++++++++------------ tests/test_package_tools.py | 17 ++++++++++++++++- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/bincrafters/build_shared.py b/bincrafters/build_shared.py index f197476..3e38633 100644 --- a/bincrafters/build_shared.py +++ b/bincrafters/build_shared.py @@ -102,23 +102,26 @@ def get_user_repository(username, repository_name): def get_conan_upload(username): + upload = os.getenv("CONAN_UPLOAD") + if upload: + return upload.split('@') if '@' in upload else upload + repository_name = os.getenv("BINTRAY_REPOSITORY", "public-conan") - return os.getenv("CONAN_UPLOAD", get_user_repository(username, repository_name)).split('@') + return get_user_repository(username, repository_name) def get_conan_remotes(username): remotes = os.getenv("CONAN_REMOTES") - if not remotes: - # While redundant, this moves upload remote to position 0. - remotes = [get_conan_upload(username)] - - # Add bincrafters repository for other users, e.g. if the package would - # require other packages from the bincrafters repo. - bincrafters_user = "bincrafters" - if username != bincrafters_user: - remotes.append(get_conan_upload(bincrafters_user)) - if isinstance(remotes, string_types): - remotes = remotes.split('@') + if remotes: + return remotes.split('@') if '@' in remotes else remotes + + # While redundant, this moves upload remote to position 0. + remotes = [get_conan_upload(username)] + # Add bincrafters repository for other users, e.g. if the package would + # require other packages from the bincrafters repo. + bincrafters_user = "bincrafters" + if username != bincrafters_user: + remotes.append(get_conan_upload(bincrafters_user)) return remotes diff --git a/tests/test_package_tools.py b/tests/test_package_tools.py index 3d4b909..e0e8924 100644 --- a/tests/test_package_tools.py +++ b/tests/test_package_tools.py @@ -38,6 +38,13 @@ def set_upload_when_stable_false(): del os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] +@pytest.fixture() +def set_upload_address(): + os.environ["CONAN_UPLOAD"] = "https://api.bintray.com/conan/foo/bar@False@remotefoo" + yield + del os.environ["CONAN_UPLOAD"] + + def test_build_template_boost_default(): builder = build_template_boost_default.get_builder() @@ -160,4 +167,12 @@ def test_upload_only_when_stable_builder(set_upload_when_stable_false): def test_upload_only_when_stable_header_only(set_upload_when_stable_false): builder = build_template_header_only.get_builder() - assert False == builder.upload_only_when_stable \ No newline at end of file + assert False == builder.upload_only_when_stable + + +def test_format_upload(set_upload_address): + builder = build_template_default.get_builder() + assert "remotefoo" == builder.remotes_manager.upload_remote_name + assert "remotefoo" == builder.remotes_manager._upload.name + assert "https://api.bintray.com/conan/foo/bar" == builder.remotes_manager._upload.url + assert 'False' == builder.remotes_manager._upload.use_ssl \ No newline at end of file From 479b0dcb093e5120994b62ea9b8dc453c6cbf5d9 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 15 Jan 2019 22:30:05 -0200 Subject: [PATCH 4/5] Remove six Signed-off-by: Uilian Ries --- bincrafters/build_shared.py | 1 - tests/test_package_tools.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/bincrafters/build_shared.py b/bincrafters/build_shared.py index 3e38633..8432e50 100644 --- a/bincrafters/build_shared.py +++ b/bincrafters/build_shared.py @@ -4,7 +4,6 @@ import os import re import platform -from six import string_types from cpt.packager import ConanMultiPackager from cpt.tools import split_colon_env diff --git a/tests/test_package_tools.py b/tests/test_package_tools.py index e0e8924..1ce7aad 100644 --- a/tests/test_package_tools.py +++ b/tests/test_package_tools.py @@ -175,4 +175,4 @@ def test_format_upload(set_upload_address): assert "remotefoo" == builder.remotes_manager.upload_remote_name assert "remotefoo" == builder.remotes_manager._upload.name assert "https://api.bintray.com/conan/foo/bar" == builder.remotes_manager._upload.url - assert 'False' == builder.remotes_manager._upload.use_ssl \ No newline at end of file + assert 'False' == builder.remotes_manager._upload.use_ssl From 1d7320ec874568bd80305e49e739023e295c0da5 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 15 Jan 2019 23:22:21 -0200 Subject: [PATCH 5/5] #506 Fix remote format Signed-off-by: Uilian Ries --- bincrafters/build_shared.py | 2 +- tests/test_package_tools.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bincrafters/build_shared.py b/bincrafters/build_shared.py index 8432e50..d745ec7 100644 --- a/bincrafters/build_shared.py +++ b/bincrafters/build_shared.py @@ -112,7 +112,7 @@ def get_conan_upload(username): def get_conan_remotes(username): remotes = os.getenv("CONAN_REMOTES") if remotes: - return remotes.split('@') if '@' in remotes else remotes + return [remotes.split('@')] if '@' in remotes else [remotes] # While redundant, this moves upload remote to position 0. remotes = [get_conan_upload(username)] diff --git a/tests/test_package_tools.py b/tests/test_package_tools.py index 1ce7aad..f2e7c57 100644 --- a/tests/test_package_tools.py +++ b/tests/test_package_tools.py @@ -45,6 +45,13 @@ def set_upload_address(): del os.environ["CONAN_UPLOAD"] +@pytest.fixture() +def set_remote_address(): + os.environ["CONAN_REMOTES"] = "https://api.bintray.com/conan/foo/bar@False@remotefoo" + yield + del os.environ["CONAN_REMOTES"] + + def test_build_template_boost_default(): builder = build_template_boost_default.get_builder() @@ -176,3 +183,11 @@ def test_format_upload(set_upload_address): assert "remotefoo" == builder.remotes_manager._upload.name assert "https://api.bintray.com/conan/foo/bar" == builder.remotes_manager._upload.url assert 'False' == builder.remotes_manager._upload.use_ssl + + +def test_format_remote(set_remote_address): + builder = build_template_default.get_builder() + remote = builder.remotes_manager._remotes[0] + assert "remotefoo" == remote.name + assert "https://api.bintray.com/conan/foo/bar" == remote.url + assert 'False' == remote.use_ssl