From 2a3939e6e6992176120e72eee3cbf84992ff7f65 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Wed, 13 Mar 2019 07:42:58 +0100 Subject: [PATCH] [build] Completely reverts building from metadata (does not work properly) --- bob/devtools/build.py | 30 ++++++++++++++++-------------- bob/devtools/scripts/build.py | 19 ++++++++----------- bob/devtools/scripts/rebuild.py | 21 ++++++--------------- 3 files changed, 30 insertions(+), 40 deletions(-) diff --git a/bob/devtools/build.py b/bob/devtools/build.py index a49a2d6d..83fd6c80 100644 --- a/bob/devtools/build.py +++ b/bob/devtools/build.py @@ -135,11 +135,11 @@ def make_conda_config(config, python, append_file, condarc_options): conda-build API's ``get_or_merge_config()`` function. ''' - from conda_build.api import get_or_merge_config from conda_build.conda_interface import url_path - retval = get_or_merge_config(None, variant_config_files=config, - python=python, append_sections_file=append_file, **condarc_options) + retval = conda_build.api.get_or_merge_config(None, + variant_config_files=config, python=python, + append_sections_file=append_file, **condarc_options) retval.channel_urls = [] @@ -159,22 +159,19 @@ def make_conda_config(config, python, append_file, condarc_options): def get_output_path(metadata, config): '''Renders the recipe and returns the name of the output file''' - from conda_build.api import get_output_file_paths - return get_output_file_paths(metadata, config=config)[0] + return conda_build.api.get_output_file_paths(metadata, config=config)[0] def get_rendered_metadata(recipe_dir, config): '''Renders the recipe and returns the interpreted YAML file''' - from conda_build.api import render - return render(recipe_dir, config=config) + return conda_build.api.render(recipe_dir, config=config) def get_parsed_recipe(metadata): '''Renders the recipe and returns the interpreted YAML file''' - from conda_build.api import output_yaml - output = output_yaml(metadata[0][0]) + output = conda_build.api.output_yaml(metadata[0][0]) return yaml.load(output) @@ -505,6 +502,12 @@ def base_build(bootstrap, server, intranet, group, recipe_dir, condarc_options: Pre-parsed condarc options loaded from the respective YAML file + + Returns: + + list: The list of built packages, as returned by + ``conda_build.api.build()`` + ''' # if you get to this point, tries to build the package @@ -552,7 +555,7 @@ def base_build(bootstrap, server, intranet, group, recipe_dir, # if you get to this point, just builds the package logger.info('Building %s', path) - conda_build.api.build(metadata[0][0]) + return conda_build.api.build(recipe_dir, config=conda_config) if __name__ == '__main__': @@ -656,8 +659,8 @@ if __name__ == '__main__': conda_config = make_conda_config(conda_build_config, args.python_version, recipe_append, condarc_options) - metadata = get_rendered_metadata(os.path.join(args.work_dir, 'conda'), - conda_config) + recipe_dir = os.path.join(args.work_dir, 'conda') + metadata = get_rendered_metadata(recipe_dir, conda_config) path = get_output_path(metadata, conda_config) # asserts we're building at the right location @@ -682,8 +685,7 @@ if __name__ == '__main__': # resolved the "wrong" build number. We'll have to reparse after setting the # environment variable BOB_BUILD_NUMBER. bootstrap.set_environment('BOB_BUILD_NUMBER', str(build_number)) - conda_build.api.build(os.path.join(args.work_dir, 'conda'), - config=conda_config) + conda_build.api.build(recipe_dir, config=conda_config) # checks if long_description of python package renders fine if args.twine_check: diff --git a/bob/devtools/scripts/build.py b/bob/devtools/scripts/build.py index a4be8d8d..c8dc8566 100644 --- a/bob/devtools/scripts/build.py +++ b/bob/devtools/scripts/build.py @@ -17,7 +17,7 @@ from ..constants import CONDA_BUILD_CONFIG, CONDA_RECIPE_APPEND, \ SERVER, MATPLOTLIB_RCDIR, BASE_CONDARC from ..bootstrap import set_environment, get_channels -from ..log import verbosity_option, get_logger +from ..log import verbosity_option, get_logger, echo_info logger = get_logger(__name__) @@ -153,19 +153,16 @@ def build(recipe_dir, python, condarc, config, no_test, append_file, # gets the next build number build_number, _ = next_build_number(channels[0], os.path.basename(path)) - # notice we cannot build from the pre-parsed metadata because it has - # already resolved the "wrong" build number. We'll have to reparse after - # setting the environment variable BOB_BUILD_NUMBER. - set_environment('BOB_BUILD_NUMBER', str(build_number)) - metadata = get_rendered_metadata(d, conda_config) - path = get_output_path(metadata, conda_config) - logger.info('Building %s-%s-py%s (build: %d) for %s', rendered_recipe['package']['name'], rendered_recipe['package']['version'], python.replace('.',''), build_number, arch) + if not dry_run: - conda_build.api.build(metadata[0][0], notest=no_test) + # 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) # if you get to this point, the package was successfully rebuilt - # set environment to signal caller we can upload it - os.environ['BDT_BUILD'] = path + # set environment to signal caller we may dispose of it + os.environ['BDT_BUILD'] = ':'.join(paths) diff --git a/bob/devtools/scripts/rebuild.py b/bob/devtools/scripts/rebuild.py index 69d7e2a8..f9ea9ccd 100644 --- a/bob/devtools/scripts/rebuild.py +++ b/bob/devtools/scripts/rebuild.py @@ -190,23 +190,14 @@ def rebuild(recipe_dir, python, condarc, config, append_file, rendered_recipe['package']['version'], python.replace('.',''), build_number, arch) - # notice we cannot build from the pre-parsed metadata because it has - # already resolved the "wrong" build number. We'll have to reparse after - # setting the environment variable BOB_BUILD_NUMBER. - set_environment('BOB_BUILD_NUMBER', str(build_number)) - metadata = get_rendered_metadata(d, conda_config) - candidate = get_output_path(metadata, conda_config) - - if os.path.exists(candidate): - logger.debug('Removing existing conda package at %s for rebuild...', - candidate) - os.unlink(candidate) - if not dry_run: - conda_build.api.build(metadata[0][0], notest=False) + # 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=False) # if you get to this point, the package was successfully rebuilt - # set environment to signal caller we can upload it - os.environ['BDT_BUILD'] = candidate + # set environment to signal caller we may dispose of it + os.environ['BDT_BUILD'] = ':'.join(paths) else: #skip build, test worked logger.info('Skipping rebuild of %s-%s-py%s (build: %d) for %s', -- GitLab