From 264e1928e8b2bf403708d2e15b41368daa24be1b Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 2 Nov 2018 16:39:49 -0300 Subject: [PATCH] #518 Allow uploading Boost packages Signed-off-by: Uilian Ries --- bincrafters/__init__.py | 2 +- bincrafters/build_shared.py | 7 +------ bincrafters/build_template_boost_default.py | 20 +++++++++---------- .../build_template_boost_header_only.py | 11 ++++++---- tests/test_package_tools.py | 20 ++++++++----------- 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/bincrafters/__init__.py b/bincrafters/__init__.py index f6049c7..921c447 100644 --- a/bincrafters/__init__.py +++ b/bincrafters/__init__.py @@ -1 +1 @@ -__version__ = '0.17.4' +__version__ = '0.17.5' diff --git a/bincrafters/build_shared.py b/bincrafters/build_shared.py index dd1c7f1..e63213d 100644 --- a/bincrafters/build_shared.py +++ b/bincrafters/build_shared.py @@ -8,11 +8,6 @@ from cpt.tools import split_colon_env -def get_bool_from_env(var_name, default="0"): - val = os.getenv(var_name) or default - return str(val).lower() in ["1", "true", "yes", "y"] - - def get_value_from_recipe(search_string, recipe="conanfile.py"): with open(recipe, "r") as conanfile: contents = conanfile.read() @@ -119,7 +114,7 @@ def get_conan_remotes(username): def get_upload_when_stable(): - return get_bool_from_env("CONAN_UPLOAD_ONLY_WHEN_STABLE", default="1") + return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True) def get_os(): diff --git a/bincrafters/build_template_boost_default.py b/bincrafters/build_template_boost_default.py index 2678990..d1d0bc6 100644 --- a/bincrafters/build_template_boost_default.py +++ b/bincrafters/build_template_boost_default.py @@ -4,6 +4,7 @@ import os from bincrafters import build_shared from bincrafters import build_template_default +from conans import tools def add_boost_shared(build): @@ -23,15 +24,14 @@ def get_builder(shared_option_name=None, # Bincrafters default is to upload only when stable, but boost is an exception # Empty string allows boost packages upload for testing branch - os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] = "" + with tools.environment_append({"CONAN_UPLOAD_ONLY_WHEN_STABLE": ""}): + shared_option_name = False if shared_option_name is None and not build_shared.is_shared() else shared_option_name - shared_option_name = False if shared_option_name is None and not build_shared.is_shared() else shared_option_name + builder = build_template_default.get_builder( + shared_option_name=shared_option_name, + pure_c=pure_c, + dll_with_static_runtime=dll_with_static_runtime, + build_policy=build_policy) + builder.builds = map(add_boost_shared, builder.items) - builder = build_template_default.get_builder( - shared_option_name=shared_option_name, - pure_c=pure_c, - dll_with_static_runtime=dll_with_static_runtime, - build_policy=build_policy) - builder.builds = map(add_boost_shared, builder.items) - - return builder + return builder diff --git a/bincrafters/build_template_boost_header_only.py b/bincrafters/build_template_boost_header_only.py index 1e2fbb9..e4aa863 100644 --- a/bincrafters/build_template_boost_header_only.py +++ b/bincrafters/build_template_boost_header_only.py @@ -3,12 +3,15 @@ import os from bincrafters import build_template_header_only +from conans import tools def get_builder(**kwargs): - # Bincrafters default is to upload only when stable, but boost is an exception - # Empty string allows boost packages upload for testing branch - os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] = "" + with tools.environment_append({"CONAN_UPLOAD_ONLY_WHEN_STABLE": ""}): - return build_template_header_only.get_builder(**kwargs) + # Bincrafters default is to upload only when stable, but boost is an exception + # Empty string allows boost packages upload for testing branch + os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] = "" + + return build_template_header_only.get_builder(**kwargs) diff --git a/tests/test_package_tools.py b/tests/test_package_tools.py index 81a10ce..de2b22c 100644 --- a/tests/test_package_tools.py +++ b/tests/test_package_tools.py @@ -21,6 +21,7 @@ def set_matrix_variables(): elif platform.system() == "Darwin": os.environ["CONAN_APPLE_CLANG_VERSIONS"] = "9.0" + @pytest.fixture() def set_minimal_build_environment(): os.environ["CONAN_ARCHS"] = "x86" @@ -29,16 +30,8 @@ def set_minimal_build_environment(): del os.environ["CONAN_ARCHS"] del os.environ["CONAN_BUILD_TYPES"] -@pytest.fixture() -def set_upload_when_stable(): - os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] = "FOOBAR" - - -def get_upload_when_stable(): - return os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] - -def test_build_template_boost_default(set_upload_when_stable): +def test_build_template_boost_default(): builder = build_template_boost_default.get_builder() for settings, options, env_vars, build_requires, reference in builder.items: @@ -54,7 +47,7 @@ def test_build_template_boost_default(set_upload_when_stable): elif platform.system() == "Darwin": assert 4 == len(builder.items) - assert "" == get_upload_when_stable() + assert builder.upload_only_when_stable == "" def test_build_template_default(): @@ -120,12 +113,12 @@ def test_build_header_only(): assert 1 == len(builder.items) -def test_build_boost_header_only(set_upload_when_stable): +def test_build_boost_header_only(): builder = build_template_boost_header_only.get_builder() for settings, options, env_vars, build_requires, reference in builder.items: assert 0 == len(options) assert 1 == len(builder.items) - assert "" == get_upload_when_stable() + assert builder.upload_only_when_stable == "" def test_get_os(): @@ -137,14 +130,17 @@ def test_ci_is_running(): expected = True if os.getenv("CI", None) is not None else False assert expected == build_shared.is_ci_running() + def test_build_policy_not_set(): builder = build_template_default.get_builder() assert None == builder.build_policy + def test_build_policy_set_in_args(): builder = build_template_default.get_builder(build_policy='missing') assert 'missing' == builder.build_policy + def test_build_policy_set_header_only(): builder = build_template_header_only.get_builder(build_policy='missing') assert 'missing' == builder.build_policy