From 56ecf17c468fba9df2b314eed7b63f356f3cf295 Mon Sep 17 00:00:00 2001 From: Yikun Jiang Date: Fri, 13 Oct 2023 20:25:39 +0800 Subject: [PATCH] address comments --- bioconda_utils/build.py | 13 +++++++------ test/test_utils.py | 11 +++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bioconda_utils/build.py b/bioconda_utils/build.py index b992000ed2..2dd6b2efd2 100644 --- a/bioconda_utils/build.py +++ b/bioconda_utils/build.py @@ -260,21 +260,21 @@ def get_subdags(dag, n_workers, worker_offset): return subdags -def do_not_consider_for_additional_platform(recipe_folder: str, recipe: str): +def do_not_consider_for_additional_platform(recipe_folder: str, recipe: str, platform: str): """ Given a recipe, check this recipe should skip in current platform or not. Arguments: recipe_folder: Directory containing possibly many, and possibly nested, recipes. - recipe: recipe name + recipe: Relative path to recipe + platform: current native platform Returns: Return True if current native platform are not included in recipe's additional platforms (no need to build). """ recipe_obj = _recipe.Recipe.from_file(recipe_folder, recipe) - native_platform = utils.RepoData().native_platform() # On linux-aarch64 env, only build recipe with linux-aarch64 extra_additional_platforms - if native_platform == "linux-aarch64": + if platform == "linux-aarch64": if "linux-aarch64" not in recipe_obj.extra_additional_platforms: return True return False @@ -377,8 +377,9 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str], failed_uploads = [] for recipe, name in recipes: - if not force and do_not_consider_for_additional_platform(recipe_folder, recipe): - logger.info("BUILD SKIP: skipping %s for additional platform", recipe) + platform = utils.RepoData().native_platform() + if not force and do_not_consider_for_additional_platform(recipe_folder, recipe, platform): + logger.info("BUILD SKIP: skipping %s for additional platform %s", recipe, platform) continue if name in skip_dependent: diff --git a/test/test_utils.py b/test/test_utils.py index 02c3f6bc76..916fb10894 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -6,7 +6,6 @@ import tempfile import requests import uuid -import unittest.mock import contextlib import tarfile import logging @@ -890,8 +889,7 @@ def test_load_meta_skipping(): assert utils.load_all_meta(recipe) == [] -@unittest.mock.patch('bioconda_utils.utils.RepoData.native_platform') -def test_native_platform_skipping(func_mock): +def test_native_platform_skipping(): expections = [ # Don't skip linux-x86 for any recipes ["one", "linux", False], @@ -920,10 +918,11 @@ def test_native_platform_skipping(func_mock): r.write_recipes() # Make sure RepoData singleton init utils.RepoData.register_config(config_fixture) - for recipe_name, native_platform, result in expections: + for recipe_name, platform, result in expections: recipe_folder = os.path.dirname(r.recipe_dirs[recipe_name]) - func_mock.return_value = native_platform - assert build.do_not_consider_for_additional_platform(recipe_folder, r.recipe_dirs[recipe_name]) == result + assert build.do_not_consider_for_additional_platform(recipe_folder, + r.recipe_dirs[recipe_name], + platform) == result def test_variants():