From 20a732e961e291facd3dc1c62db0bb2780a950da Mon Sep 17 00:00:00 2001 From: Marcel Bargull Date: Sat, 1 Jun 2024 22:55:15 +0200 Subject: [PATCH] fix: Pass pkg_format to container-based build Signed-off-by: Marcel Bargull --- bioconda_utils/docker_utils.py | 21 ++++++++------------- test/test_utils.py | 9 --------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/bioconda_utils/docker_utils.py b/bioconda_utils/docker_utils.py index af56a316f8..3296cf8841 100644 --- a/bioconda_utils/docker_utils.py +++ b/bioconda_utils/docker_utils.py @@ -105,6 +105,9 @@ grep -vF "Warning: 'file://{self.container_staging}' already in 'channels' list, moving to the top" >&2 ) +# Pass on conda_pkg_format ("2" for .conda instead of .tar.bz2) from host's conda-build config. +test -n '{self.conda_pkg_format}' && conda config --set conda_build.pkg_format '{self.conda_pkg_format}' + # The actual building... # we explicitly point to the meta.yaml, in order to keep # conda-build from building all subdirectories @@ -155,18 +158,6 @@ class DockerBuildError(Exception): -def get_host_conda_bld(): - """ - Identifies the conda-bld directory on the host. - - Assumes that conda-build is installed. - """ - # v0.16.2: this used to have a side effect, calling conda build purge - # hopefully, it's not actually needed. - build_conf = utils.load_conda_build_config() - return build_conf.build_folder - - class RecipeBuilder(object): def __init__( self, @@ -286,7 +277,11 @@ def __init__( self.container_recipe = container_recipe self.container_staging = container_staging - self.host_conda_bld = get_host_conda_bld() + conda_build_config = utils.load_conda_build_config() + # Identify conda-bld directory on the host. + self.host_conda_bld = conda_build_config.croot + # Pass on config to choose wheter to build .tar.bz2 or .conda format. + self.conda_pkg_format = conda_build_config.conda_pkg_format or "" if use_host_conda_bld: self.pkg_dir = self.host_conda_bld diff --git a/test/test_utils.py b/test/test_utils.py index 8b46c4c89b..4ec044dd7f 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1291,18 +1291,9 @@ def test_pkg_test_conda_package_format( r.write_recipes() docker_builder = None if mulled_test: - # Override conda_build.pkg_format in build_script_template. - build_script_template = re.sub( - "^(conda config.*)", - f"conda config --set conda_build.pkg_format {pkg_format}\n\\1", - docker_utils.BUILD_SCRIPT_TEMPLATE, - count=1, - flags=re.M, - ) docker_builder = docker_utils.RecipeBuilder( use_host_conda_bld=True, docker_base_image=DOCKER_BASE_IMAGE, - build_script_template=build_script_template, ) build_result = build.build_recipes( r.basedir,