Skip to content
Snippets Groups Projects
Commit ac1e9f27 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Merge branch 'conda-build-from-metadata' into 'master'

No config set when using conda_build.api.build() directly from metadata

Closes bob.conda#68

See merge request !33
parents 50bac239 2a3939e6
No related branches found
No related tags found
1 merge request!33No config set when using conda_build.api.build() directly from metadata
Pipeline #28036 passed
...@@ -135,11 +135,11 @@ def make_conda_config(config, python, append_file, condarc_options): ...@@ -135,11 +135,11 @@ def make_conda_config(config, python, append_file, condarc_options):
conda-build API's ``get_or_merge_config()`` function. 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 from conda_build.conda_interface import url_path
retval = get_or_merge_config(None, variant_config_files=config, retval = conda_build.api.get_or_merge_config(None,
python=python, append_sections_file=append_file, **condarc_options) variant_config_files=config, python=python,
append_sections_file=append_file, **condarc_options)
retval.channel_urls = [] retval.channel_urls = []
...@@ -159,22 +159,19 @@ def make_conda_config(config, python, append_file, condarc_options): ...@@ -159,22 +159,19 @@ def make_conda_config(config, python, append_file, condarc_options):
def get_output_path(metadata, config): def get_output_path(metadata, config):
'''Renders the recipe and returns the name of the output file''' '''Renders the recipe and returns the name of the output file'''
from conda_build.api import get_output_file_paths return conda_build.api.get_output_file_paths(metadata, config=config)[0]
return get_output_file_paths(metadata, config=config)[0]
def get_rendered_metadata(recipe_dir, config): def get_rendered_metadata(recipe_dir, config):
'''Renders the recipe and returns the interpreted YAML file''' '''Renders the recipe and returns the interpreted YAML file'''
from conda_build.api import render return conda_build.api.render(recipe_dir, config=config)
return render(recipe_dir, config=config)
def get_parsed_recipe(metadata): def get_parsed_recipe(metadata):
'''Renders the recipe and returns the interpreted YAML file''' '''Renders the recipe and returns the interpreted YAML file'''
from conda_build.api import output_yaml output = conda_build.api.output_yaml(metadata[0][0])
output = output_yaml(metadata[0][0])
return yaml.load(output) return yaml.load(output)
...@@ -505,6 +502,12 @@ def base_build(bootstrap, server, intranet, group, recipe_dir, ...@@ -505,6 +502,12 @@ def base_build(bootstrap, server, intranet, group, recipe_dir,
condarc_options: Pre-parsed condarc options loaded from the respective YAML condarc_options: Pre-parsed condarc options loaded from the respective YAML
file 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 # if you get to this point, tries to build the package
...@@ -552,7 +555,7 @@ def base_build(bootstrap, server, intranet, group, recipe_dir, ...@@ -552,7 +555,7 @@ def base_build(bootstrap, server, intranet, group, recipe_dir,
# if you get to this point, just builds the package # if you get to this point, just builds the package
logger.info('Building %s', path) logger.info('Building %s', path)
conda_build.api.build(metadata[0][0], config=conda_config) return conda_build.api.build(recipe_dir, config=conda_config)
if __name__ == '__main__': if __name__ == '__main__':
...@@ -656,8 +659,8 @@ if __name__ == '__main__': ...@@ -656,8 +659,8 @@ if __name__ == '__main__':
conda_config = make_conda_config(conda_build_config, args.python_version, conda_config = make_conda_config(conda_build_config, args.python_version,
recipe_append, condarc_options) recipe_append, condarc_options)
metadata = get_rendered_metadata(os.path.join(args.work_dir, 'conda'), recipe_dir = os.path.join(args.work_dir, 'conda')
conda_config) metadata = get_rendered_metadata(recipe_dir, conda_config)
path = get_output_path(metadata, conda_config) path = get_output_path(metadata, conda_config)
# asserts we're building at the right location # asserts we're building at the right location
...@@ -682,8 +685,7 @@ if __name__ == '__main__': ...@@ -682,8 +685,7 @@ if __name__ == '__main__':
# resolved the "wrong" build number. We'll have to reparse after setting the # resolved the "wrong" build number. We'll have to reparse after setting the
# environment variable BOB_BUILD_NUMBER. # environment variable BOB_BUILD_NUMBER.
bootstrap.set_environment('BOB_BUILD_NUMBER', str(build_number)) bootstrap.set_environment('BOB_BUILD_NUMBER', str(build_number))
conda_build.api.build(os.path.join(args.work_dir, 'conda'), conda_build.api.build(recipe_dir, config=conda_config)
config=conda_config)
# checks if long_description of python package renders fine # checks if long_description of python package renders fine
if args.twine_check: if args.twine_check:
......
...@@ -17,7 +17,7 @@ from ..constants import CONDA_BUILD_CONFIG, CONDA_RECIPE_APPEND, \ ...@@ -17,7 +17,7 @@ from ..constants import CONDA_BUILD_CONFIG, CONDA_RECIPE_APPEND, \
SERVER, MATPLOTLIB_RCDIR, BASE_CONDARC SERVER, MATPLOTLIB_RCDIR, BASE_CONDARC
from ..bootstrap import set_environment, get_channels 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__) logger = get_logger(__name__)
...@@ -153,19 +153,16 @@ def build(recipe_dir, python, condarc, config, no_test, append_file, ...@@ -153,19 +153,16 @@ def build(recipe_dir, python, condarc, config, no_test, append_file,
# gets the next build number # gets the next build number
build_number, _ = next_build_number(channels[0], os.path.basename(path)) 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', logger.info('Building %s-%s-py%s (build: %d) for %s',
rendered_recipe['package']['name'], rendered_recipe['package']['name'],
rendered_recipe['package']['version'], python.replace('.',''), rendered_recipe['package']['version'], python.replace('.',''),
build_number, arch) build_number, arch)
if not dry_run: if not dry_run:
conda_build.api.build(metadata[0][0], config=conda_config, 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 # if you get to this point, the package was successfully rebuilt
# set environment to signal caller we can upload it # set environment to signal caller we may dispose of it
os.environ['BDT_BUILD'] = path os.environ['BDT_BUILD'] = ':'.join(paths)
...@@ -190,23 +190,14 @@ def rebuild(recipe_dir, python, condarc, config, append_file, ...@@ -190,23 +190,14 @@ def rebuild(recipe_dir, python, condarc, config, append_file,
rendered_recipe['package']['version'], python.replace('.',''), rendered_recipe['package']['version'], python.replace('.',''),
build_number, arch) 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: if not dry_run:
conda_build.api.build(metadata[0][0], config=conda_config, 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 # if you get to this point, the package was successfully rebuilt
# set environment to signal caller we can upload it # set environment to signal caller we may dispose of it
os.environ['BDT_BUILD'] = candidate os.environ['BDT_BUILD'] = ':'.join(paths)
else: #skip build, test worked else: #skip build, test worked
logger.info('Skipping rebuild of %s-%s-py%s (build: %d) for %s', logger.info('Skipping rebuild of %s-%s-py%s (build: %d) for %s',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment