Skip to content

Commit

Permalink
add support for excluding otherwise-selected recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
daler committed Mar 11, 2024
1 parent 18f988d commit 51e70d7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
10 changes: 9 additions & 1 deletion bioconda_utils/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str],
mulled_conda_image: str = pkg_test.MULLED_CONDA_IMAGE,
record_build_failures: bool = False,
skiplist_leafs: bool = False,
live_logs: bool = True):
live_logs: bool = True,
exclude = List[str] = None,
):
"""
Build one or many bioconda packages.
Expand Down Expand Up @@ -329,6 +331,8 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str],
keep_old_work: Do not remove anything from environment, even after successful build and test.
skiplist_leafs: If True, blacklist leaf packages that fail to build
live_logs: If True, enable live logging during the build process
exclude: list of recipes to exclude. Typically used for
temporary exclusion; otherwise consider adding recipe to skiplist.
"""
if not recipes:
logger.info("Nothing to be done.")
Expand All @@ -354,6 +358,8 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str],
linter = lint.Linter(config, recipe_folder, lint_exclude)
else:
linter = None
if not exclude:
exclude = []

failed = []

Expand Down Expand Up @@ -384,6 +390,8 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str],
failed_uploads = []

for recipe, name in recipes:
if recipe in exclude:
continue
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)
Expand Down
8 changes: 6 additions & 2 deletions bioconda_utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ def do_lint(recipe_folder, config, packages="*", cache=None, list_checks=False,
@arg("--record-build-failures", action="store_true", help="Record build failures in build_failure.yaml next to the recipe.")
@arg("--skiplist-leafs", action="store_true", help="Skiplist leaf recipes (i.e. ones that are not depended on by any other recipes) that fail to build.")
@arg('--disable-live-logs', action='store_true', help="Disable live logging during the build process")
@arg('--exclude', nargs='+', help='Packages to exclude during this run')
@enable_logging()
def build(recipe_folder, config, packages="*", git_range=None, testonly=False,
force=False, docker=None, mulled_test=False, build_script_template=None,
Expand All @@ -445,7 +446,8 @@ def build(recipe_folder, config, packages="*", git_range=None, testonly=False,
docker_base_image=None,
record_build_failures=False,
skiplist_leafs=False,
disable_live_logs=False):
disable_live_logs=False,
exclude=None):
cfg = utils.load_config(config)
setup = cfg.get('setup', None)
if setup:
Expand Down Expand Up @@ -506,7 +508,9 @@ def build(recipe_folder, config, packages="*", git_range=None, testonly=False,
mulled_conda_image=mulled_conda_image,
record_build_failures=record_build_failures,
skiplist_leafs=skiplist_leafs,
live_logs=(not disable_live_logs))
live_logs=(not disable_live_logs),
exclude=exclude,
)
exit(0 if success else 1)


Expand Down
31 changes: 31 additions & 0 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,37 @@ def multi_build(request, recipes_fixture, config_fixture):
ensure_missing(pkg)


@pytest.fixture(scope='module', params=PARAMS, ids=IDS)
def multi_build_exclude(request, recipes_fixture, config_fixture):
"""
Builds the "one" and "two" recipes; provides (but then excludes) the
"three" recipe.
"""
if request.param:
docker_builder = docker_utils.RecipeBuilder(
use_host_conda_bld=True,
docker_base_image=DOCKER_BASE_IMAGE)
mulled_test = True
else:
docker_builder = None
mulled_test = False
logger.error("Fixture: Building one/two (and not three) %s",
"within docker" if docker_builder else "locally")
build.build_recipes(recipes_fixture.basedir, config_fixture,
recipes_fixture.recipe_dirnames,
docker_builder=docker_builder,
mulled_test=mulled_test,
exclude=['three'],
)
logger.error("Fixture: Building one/two (and not three) %s -- DONE",
"within docker" if docker_builder else "locally")
built_packages = recipes_fixture.pkgs
yield built_packages
for pkgs in built_packages.values():
for pkg in pkgs:
ensure_missing(pkg)


@pytest.fixture(scope='module')
def single_upload():
"""
Expand Down

0 comments on commit 51e70d7

Please sign in to comment.