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

[build] Check specific version of python builds (if needed); Be more...

[build] Check specific version of python builds (if needed); Be more consistent when outputing package names
parent 67827080
No related branches found
No related tags found
1 merge request!11Independent builds and python support
Pipeline #26805 passed
...@@ -154,7 +154,8 @@ def get_parsed_recipe(metadata): ...@@ -154,7 +154,8 @@ def get_parsed_recipe(metadata):
return yaml.load(output) return yaml.load(output)
def exists_on_channel(channel_url, name, version, build_number): def exists_on_channel(channel_url, name, version, build_number,
python_version):
"""Checks on the given channel if a package with the specs exist """Checks on the given channel if a package with the specs exist
Args: Args:
...@@ -164,31 +165,48 @@ def exists_on_channel(channel_url, name, version, build_number): ...@@ -164,31 +165,48 @@ def exists_on_channel(channel_url, name, version, build_number):
name: The name of the package name: The name of the package
version: The version of the package version: The version of the package
build_number: The build number of the package build_number: The build number of the package
python_version: The current version of python we're building for
Returns: ``True``, if the package already exists in the channel or ``False`` Returns: A complete package name, version and build string, if the package
otherwise already exists in the channel or ``None`` otherwise.
""" """
from conda.exports import get_index from conda.exports import get_index
# no dot in py_ver
py_ver = python_version.replace('.', '')
# get the channel index # get the channel index
logger.debug('Downloading channel index from %s', channel_url) logger.debug('Downloading channel index from %s', channel_url)
index = get_index(channel_urls=[channel_url], prepend=False) index = get_index(channel_urls=[channel_url], prepend=False)
logger.info('Checking for %s-%s_*_%s...', name, version, build_number) logger.info('Checking for %s-%s-%s...', name, version, build_number)
for dist in index: for dist in index:
if dist.name == name and dist.version == version and \ if dist.name == name and dist.version == version and \
dist.build_string.endswith('_%s' % build_number): dist.build_string.endswith('_%s' % build_number):
match = re.match('py[2-9][0-9]+', dist.build_string)
logger.info('Found matching package (%s-%s_%s)', dist.name, dist.version,
dist.build_string)
return True
logger.info('No matches for %s-%s_%s found among %d packages', # two possible options must be checked - (i) the package build_string
name, version, build_number, len(index)) # starts with ``py``, which means it is a python specific package so we
return False # must also check for the matching python version. (ii) the package is
# not a python-specific package and a simple match will do
if dist.build_string.startswith('py'):
match = re.match('py[2-9][0-9]+', dist.build_string)
if match and match.group() == 'py{}'.format(py_ver):
logger.debug('Found matching package (%s-%s-%s)', dist.name,
dist.version, dist.build_string)
return (dist.name, dist.version, dist.build_string)
else:
logger.debug('Found matching package (%s-%s-%s)', dist.name,
dist.version, dist.build_string)
return (dist.name, dist.version, dist.build_string)
logger.info('No matches for %s-%s-(py%s_?)%s found among %d packages',
name, version, py_ver, build_number, len(index))
return
def remove_pins(deps): def remove_pins(deps):
...@@ -444,7 +462,8 @@ def git_clean_build(runner, verbose): ...@@ -444,7 +462,8 @@ def git_clean_build(runner, verbose):
['--exclude=%s' % k for k in exclude_from_cleanup]) ['--exclude=%s' % k for k in exclude_from_cleanup])
def base_build(server, intranet, recipe_dir, config): def base_build(server, intranet, recipe_dir, conda_build_config,
python_version, condarc_options):
'''Builds a non-beat/bob software dependence that does not exist on defaults '''Builds a non-beat/bob software dependence that does not exist on defaults
This function will build a software dependence that is required for our This function will build a software dependence that is required for our
...@@ -460,33 +479,49 @@ def base_build(server, intranet, recipe_dir, config): ...@@ -460,33 +479,49 @@ def base_build(server, intranet, recipe_dir, config):
intranet: Boolean indicating if we should add "private"/"public" prefixes intranet: Boolean indicating if we should add "private"/"public" prefixes
on the returned paths on the returned paths
recipe_dir: The directory containing the recipe's ``meta.yaml`` file recipe_dir: The directory containing the recipe's ``meta.yaml`` file
config: A dictionary containing the merged configuration, as produced by conda_build_config: Path to the ``conda_build_config.yaml`` file to use
conda-build API's ``get_or_merge_config()`` function python_version: String with the python version to build for, in the format
``x.y`` (should be passed even if not building a python package)
condarc_options: Pre-parsed condarc options loaded from the respective YAML
file
''' '''
# if you get to this point, tries to build the package # if you get to this point, tries to build the package
public_channel = bootstrap.get_channels(public=True, stable=True, public_channels = bootstrap.get_channels(public=True, stable=True,
server=server, intranet=intranet)[0] server=server, intranet=intranet)
metadata = get_rendered_metadata(recipe_dir, config)
logger.info('Using the following channels during (potential) build:\n - %s',
'\n - '.join(public_channels + ['defaults']))
condarc_options['channels'] = public_channels + ['defaults']
logger.info('Merging conda configuration files...')
conda_config = make_conda_config(conda_build_config, python_version,
None, condarc_options)
metadata = get_rendered_metadata(recipe_dir, conda_config)
recipe = get_parsed_recipe(metadata) recipe = get_parsed_recipe(metadata)
if recipe is None: if recipe is None:
logger.warn('Skipping build for %s - rendering returned None', recipe_dir) logger.info('Skipping build for %s - rendering returned None', recipe_dir)
return return
if exists_on_channel(public_channel, recipe['package']['name'], # no dot in py_ver
recipe['package']['version'], recipe['build']['number']): py_ver = python_version.replace('.', '')
logger.warn('Skipping build for %s-%s_%s - exists on channel already', arch = conda_arch()
recipe['package']['name'], recipe['package']['version'],
recipe['build']['number']) candidate = exists_on_channel(public_channels[0], recipe['package']['name'],
recipe['package']['version'], recipe['build']['number'],
python_version)
if candidate is not None:
logger.info('Skipping build for %s-%s-(py%s_?)%s for %s - exists ' \
'on channel', candidate[0], candidate[1], candidate[2], py_ver)
return return
# if you get to this point, just builds the package # if you get to this point, just builds the package
arch = conda_arch() logger.info('Building %s-%s-(py%s_?)%s for %s',
logger.info('Building %s-%s (build: %d) for %s',
recipe['package']['name'], recipe['package']['version'], recipe['package']['name'], recipe['package']['version'],
recipe['build']['number'], arch) recipe['build']['number'], py_ver, arch)
conda_build.api.build(recipe_dir, config=conda_config) conda_build.api.build(recipe_dir, config=conda_config)
...@@ -559,23 +594,9 @@ if __name__ == '__main__': ...@@ -559,23 +594,9 @@ if __name__ == '__main__':
with open(condarc, 'rb') as f: with open(condarc, 'rb') as f:
condarc_options = yaml.load(f) condarc_options = yaml.load(f)
# 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' )
channels = bootstrap.get_channels(public=public, stable=(not is_prerelease),
server=server, intranet=(not args.internet))
logger.info('Using the following channels during build:\n - %s',
'\n - '.join(channels + ['defaults']))
condarc_options['channels'] = channels + ['defaults']
# dump packages at conda_root # dump packages at conda_root
condarc_options['croot'] = os.path.join(args.conda_root, 'conda-bld') condarc_options['croot'] = os.path.join(args.conda_root, 'conda-bld')
logger.info('Merging conda configuration files...')
conda_config = make_conda_config(conda_build_config, args.python_version,
recipe_append, condarc_options)
# builds all dependencies in the 'deps' subdirectory - or at least checks # builds all dependencies in the 'deps' subdirectory - or at least checks
# these dependencies are already available; these dependencies go directly to # these dependencies are already available; these dependencies go directly to
# the public channel once built # the public channel once built
...@@ -583,13 +604,28 @@ if __name__ == '__main__': ...@@ -583,13 +604,28 @@ if __name__ == '__main__':
if not os.path.exists(os.path.join(recipe, 'meta.yaml')): if not os.path.exists(os.path.join(recipe, 'meta.yaml')):
# ignore - not a conda package # ignore - not a conda package
continue continue
base_build(server, not args.internet, recipe, conda_config) base_build(server, not args.internet, recipe, conda_build_config,
args.python_version, 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' )
channels = bootstrap.get_channels(public=public, stable=(not is_prerelease),
server=server, intranet=(not args.internet))
logger.info('Using the following channels during build:\n - %s',
'\n - '.join(channels + ['defaults']))
condarc_options['channels'] = channels + ['defaults']
# retrieve the current build number for this build # retrieve the current build number for this build
build_number, _ = next_build_number(channels[0], args.name, version, build_number, _ = next_build_number(channels[0], args.name, version,
args.python_version) args.python_version)
bootstrap.set_environment('BOB_BUILD_NUMBER', str(build_number)) bootstrap.set_environment('BOB_BUILD_NUMBER', str(build_number))
logger.info('Merging conda configuration files...')
conda_config = make_conda_config(conda_build_config, args.python_version,
recipe_append, condarc_options)
# runs the build using the conda-build API # runs the build using the conda-build API
arch = conda_arch() arch = conda_arch()
logger.info('Building %s-%s-py%s (build: %d) for %s', logger.info('Building %s-%s-py%s (build: %d) for %s',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment