diff --git a/bob/devtools/bootstrap.py b/bob/devtools/bootstrap.py index 0ef25adb8a344cfa5e5372d131cdc5546464c004..42c58facd9aabeaabec006f4d414337715e1cac8 100644 --- a/bob/devtools/bootstrap.py +++ b/bob/devtools/bootstrap.py @@ -10,8 +10,6 @@ add_pip_as_python_dependency: false #!final always_yes: true #!final anaconda_upload: false #!final channel_priority: strict #!final -channels: - - defaults conda_build: #!final pkg_format: '2' default_channels: #!final diff --git a/bob/devtools/build.py b/bob/devtools/build.py index 7228ed89677cfcfe603100fb94e50fede8d8b4df..629f63deebf2a2c2cb8c94e9bfac2261cd6fd348 100644 --- a/bob/devtools/build.py +++ b/bob/devtools/build.py @@ -602,17 +602,18 @@ def base_build( """ # if you get to this point, tries to build the package - public_channels = bootstrap.get_channels( - public=True, stable=True, server=server, intranet=intranet, group=group + channels = bootstrap.get_channels( + public=True, stable=True, server=server, intranet=intranet, + group=group ) - all_channels = public_channels + ["defaults"] + if "channels" not in condarc_options: + condarc_options["channels"] = channels + ["defaults"] + logger.info( "Using the following channels during (potential) build:\n - %s", - "\n - ".join(all_channels), + "\n - ".join(condarc_options["channels"]), ) - condarc_options["channels"] = all_channels - logger.info("Merging conda configuration files...") if python_version not in ("noarch", None): conda_config = make_conda_config( @@ -656,7 +657,7 @@ def base_build( path = get_output_path(metadata, conda_config) - url = exists_on_channel(public_channels[0], os.path.basename(path)) + url = exists_on_channel(channels[0], os.path.basename(path)) if url is not None: logger.info("Skipping build for %s as it exists (at %s)", path, url) return @@ -811,10 +812,7 @@ if __name__ == "__main__": condarc_options, ) - # notice this condarc typically will only contain the defaults channel - we - # need to boost this up with more channels to get it right for this package's - # build - public = args.visibility == "public" + public = (args.visibility == "public") channels = bootstrap.get_channels( public=public, stable=(not is_prerelease), @@ -822,12 +820,14 @@ if __name__ == "__main__": intranet=(not args.internet), group=args.group, ) + + if "channels" not in condarc_options: + condarc_options["channels"] = channels + ["defaults"] + logger.info( "Using the following channels during build:\n - %s", - "\n - ".join(channels + ["defaults"]), + "\n - ".join(condarc_options["channels"]), ) - condarc_options["channels"] = channels + ["defaults"] - logger.info("Merging conda configuration files...") conda_config = make_conda_config( conda_build_config, args.python_version, recipe_append, condarc_options diff --git a/bob/devtools/scripts/build.py b/bob/devtools/scripts/build.py index e052dcf85fa945ceedfc8fde64a70011f93c5748..9bc98d4566b7959b82e77ff72e7732547bfbee76 100644 --- a/bob/devtools/scripts/build.py +++ b/bob/devtools/scripts/build.py @@ -192,7 +192,14 @@ def build( project_dir = os.path.dirname(recipe_dir[0]) - # get potential channel upload and other auxiliary channels + if condarc is not None: + logger.info("Loading CONDARC file from %s...", condarc) + with open(condarc, "rb") as f: + condarc_options = yaml.load(f, Loader=yaml.FullLoader) + else: + # use default + condarc_options = yaml.load(BASE_CONDARC, Loader=yaml.FullLoader) + channels = get_channels( public=(not private), stable=stable, @@ -201,20 +208,15 @@ def build( group=group, ) - if condarc is not None: - logger.info("Loading CONDARC file from %s...", condarc) - with open(condarc, "rb") as f: - condarc_options = yaml.load(f, Loader=yaml.FullLoader) - else: - # use default and add channels - all_channels = [] - all_channels += channels + ["defaults"] - condarc_options = yaml.load(BASE_CONDARC, Loader=yaml.FullLoader) - logger.info( - "Using the following channels during build:\n - %s", - "\n - ".join(all_channels), - ) - condarc_options["channels"] = all_channels + if "channels" not in condarc_options: + condarc_options["channels"] = channels + ["defaults"] + + logger.info( + "Using the following channels during (potential) build:\n - %s", + "\n - ".join(condarc_options["channels"]), + ) + + logger.info("Uploading resulting package to: %s", channels[0]) # dump packages at base environment prefix = get_env_directory(os.environ["CONDA_EXE"], "base") @@ -279,8 +281,8 @@ def build( ) if not dry_run: - # set $BOB_BUILD_NUMBER and force conda_build to reparse recipe to get it - # right + # set $BOB_BUILD_NUMBER and force conda_build to reparse recipe to + # get it right set_environment("BOB_BUILD_NUMBER", str(build_number)) paths = conda_build.api.build( d, config=conda_config, notest=no_test diff --git a/bob/devtools/scripts/ci.py b/bob/devtools/scripts/ci.py index 8f4cfdcd1f9c368fc8c06fa20265e7d7fc906dc1..792f818e4b0de2db05dec30b9848f22fa7fdc4cb 100644 --- a/bob/devtools/scripts/ci.py +++ b/bob/devtools/scripts/ci.py @@ -381,25 +381,8 @@ def base_build(order, group, python, dry_run): condarc_options = yaml.load(f, Loader=yaml.FullLoader) else: # not building on the CI? - use defaults - from ..bootstrap import get_channels - - # get potential channel upload and other auxiliary channels - channels = get_channels( - public=True, - stable=True, - server=SERVER, - intranet="True", - group="bob", - ) - - # use default and add channels + # use default condarc_options = yaml.load(BASE_CONDARC, Loader=yaml.FullLoader) - channels = ["local"] + channels + ["defaults"] - logger.info( - "Using the following channels during build:\n - %s", - "\n - ".join(channels), - ) - condarc_options["channels"] = channels # dump packages at conda_root condarc_options["croot"] = os.path.join( diff --git a/bob/devtools/scripts/create.py b/bob/devtools/scripts/create.py index c397945ccf7813880853b914541132b8e705215a..5de537fe24c922da45d85a1c1e721c65c6bf13f7 100644 --- a/bob/devtools/scripts/create.py +++ b/bob/devtools/scripts/create.py @@ -16,7 +16,7 @@ from ..constants import ( CONDA_RECIPE_APPEND, SERVER, ) -from ..bootstrap import set_environment, get_channels +from ..bootstrap import set_environment from ..log import verbosity_option, get_logger, echo_normal @@ -209,17 +209,26 @@ def create( with open(condarc, "rb") as f: condarc_options = yaml.load(f, Loader=yaml.FullLoader) else: - # use default and add channels + # use default condarc_options = yaml.load(BASE_CONDARC, Loader=yaml.FullLoader) + + if "channels" not in condarc_options: + from ..bootstrap import get_channels channels = get_channels( public=(not private), stable=stable, server=server, - intranet=private, - group=group, + intranet=ci, + group=group ) condarc_options["channels"] = channels + ["defaults"] + logger.info( + "Using the following channels during environment creation:" \ + "\n - %s", + "\n - ".join(condarc_options["channels"]), + ) + conda_config = make_conda_config( config, python, append_file, condarc_options ) diff --git a/bob/devtools/scripts/graph.py b/bob/devtools/scripts/graph.py index b7b1ee362c0d35b25fc2fd6d7e95140b565a17a7..d3edfe03c43443b7c26148728a2d3a29fd00915a 100644 --- a/bob/devtools/scripts/graph.py +++ b/bob/devtools/scripts/graph.py @@ -170,15 +170,16 @@ def graph(package, python, condarc, config, append_file, server, private, with open(condarc, "rb") as f: condarc_options = yaml.load(f, Loader=yaml.FullLoader) else: - # use default and add channels - all_channels = [] - all_channels += channels + ["defaults"] + # use default condarc_options = yaml.load(BASE_CONDARC, Loader=yaml.FullLoader) - logger.info( - "Using the following channels during build:\n - %s", - "\n - ".join(all_channels), - ) - condarc_options["channels"] = all_channels + + if "channels" not in condarc_options: + condarc_options["channels"] = channels + ["defaults"] + + logger.info( + "Using the following channels during graph operation:\n - %s", + "\n - ".join(condarc_options["channels"]), + ) conda_config = make_conda_config( config, python, append_file, condarc_options diff --git a/bob/devtools/scripts/rebuild.py b/bob/devtools/scripts/rebuild.py index 3c4ded79cd38ef6a72714fb8af96f6a2a2af0059..c7bb655ceda3175d3fd6d6c4650452ee0ceff68e 100644 --- a/bob/devtools/scripts/rebuild.py +++ b/bob/devtools/scripts/rebuild.py @@ -192,14 +192,19 @@ def rebuild( with open(condarc, "rb") as f: condarc_options = yaml.load(f, Loader=yaml.FullLoader) else: - # use default and add channels + # use default condarc_options = yaml.load(BASE_CONDARC, Loader=yaml.FullLoader) - logger.info( - "Using the following channels during build:\n - %s", - "\n - ".join(channels + ["defaults"]), - ) + + if "channels" not in condarc_options: condarc_options["channels"] = channels + ["defaults"] + logger.info( + "Using the following channels during (potential) build:\n - %s", + "\n - ".join(condarc_options["channels"]), + ) + + logger.info("Uploading resulting package to: %s", channels[0]) + # dump packages at base environment prefix = get_env_directory(os.environ["CONDA_EXE"], "base") condarc_options["croot"] = os.path.join(prefix, "conda-bld") @@ -270,10 +275,10 @@ def rebuild( logger.info("Downloading %s -> %s", src, destpath) urllib.request.urlretrieve(src, destpath) - # conda_build may either raise an exception or return ``False`` in case - # the build fails, depending on the reason. This bit of code tries to - # accomodate both code paths and decides if we should rebuild the package - # or not + # conda_build may either raise an exception or return ``False`` in + # case the build fails, depending on the reason. This bit of code + # tries to accomodate both code paths and decides if we should + # rebuild the package or not logger.info("Testing %s", src) try: result = conda_build.api.test(destpath, config=conda_config) diff --git a/bob/devtools/scripts/test.py b/bob/devtools/scripts/test.py index 2c7f289190cae5cbc732f5c3804cca872752aa87..be73018cafdd5d649acc987e3d8b0d79789a0c6c 100644 --- a/bob/devtools/scripts/test.py +++ b/bob/devtools/scripts/test.py @@ -26,7 +26,7 @@ from ..constants import ( MATPLOTLIB_RCDIR, BASE_CONDARC, ) -from ..bootstrap import set_environment, get_channels +from ..bootstrap import set_environment from ..log import verbosity_option, get_logger @@ -163,29 +163,33 @@ def test( group, ) - # get potential channel upload and other auxiliary channels - channels = get_channels( - public=(not private), - stable=stable, - server=server, - intranet=ci, - group=group, - ) - if condarc is not None: logger.info("Loading CONDARC file from %s...", condarc) with open(condarc, "rb") as f: condarc_options = yaml.load(f, Loader=yaml.FullLoader) else: - # use default and add channels - all_channels = [] - all_channels += channels + ["defaults"] + # use default condarc_options = yaml.load(BASE_CONDARC, Loader=yaml.FullLoader) - logger.info( - "Using the following channels during build:\n - %s", - "\n - ".join(all_channels), + + if "channels" not in condarc_options: + from ..bootstrap import get_channels + channels = get_channels( + public=(not private), + stable=stable, + server=server, + intranet=ci, + group=group ) - condarc_options["channels"] = all_channels + condarc_options["channels"] = channels + ["defaults"] + + logger.info( + "Using the following channels during (potential) build:\n - %s", + "\n - ".join(condarc_options["channels"]), + ) + + # test packages from base environment + prefix = get_env_directory(os.environ["CONDA_EXE"], "base") + condarc_options["croot"] = os.path.join(prefix, "conda-bld") conda_config = make_conda_config(config, None, append_file, condarc_options)