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

[build] Small clean-up - save conda packages on the root conda installation

parent 3a8ab35f
No related branches found
No related tags found
No related merge requests found
Pipeline #26083 passed
...@@ -348,17 +348,13 @@ if __name__ == '__main__': ...@@ -348,17 +348,13 @@ if __name__ == '__main__':
if sys.argv[1] == 'test': if sys.argv[1] == 'test':
# sets up local variables for testing # sets up local variables for testing
set_environment('CI_PROJECT_DIR', os.path.realpath(os.curdir), verbose=True)
set_environment('CI_PROJECT_NAME', 'bob.devtools', verbose=True) set_environment('CI_PROJECT_NAME', 'bob.devtools', verbose=True)
set_environment('CONDA_ROOT', os.path.join(os.environ['CI_PROJECT_DIR'], set_environment('CONDA_ROOT', os.path.join(os.path.realpath(os.curdir),
'miniconda'), verbose=True) 'miniconda'), verbose=True)
prefix = os.environ['CONDA_ROOT'] prefix = os.environ['CONDA_ROOT']
logger.info('os.environ["%s"] = %s', 'CONDA_ROOT', prefix) logger.info('os.environ["%s"] = %s', 'CONDA_ROOT', prefix)
workdir = os.environ['CI_PROJECT_DIR']
logger.info('os.environ["%s"] = %s', 'CI_PROJECT_DIR', workdir)
install_miniconda(prefix) install_miniconda(prefix)
conda_bin = os.path.join(prefix, 'bin', 'conda') conda_bin = os.path.join(prefix, 'bin', 'conda')
......
...@@ -436,6 +436,9 @@ if __name__ == '__main__': ...@@ -436,6 +436,9 @@ if __name__ == '__main__':
'\n - '.join(channels + ['defaults'])) '\n - '.join(channels + ['defaults']))
condarc_options['channels'] = channels + ['defaults'] condarc_options['channels'] = channels + ['defaults']
# dump packages at conda_root
condarc_options['croot'] = os.path.join(prefix, 'conda-bld')
logger.info('Merging conda configuration files...') logger.info('Merging conda configuration files...')
conda_config = make_conda_config(conda_build_config, pyver, recipe_append, conda_config = make_conda_config(conda_build_config, pyver, recipe_append,
condarc_options) condarc_options)
......
...@@ -15,7 +15,7 @@ from . import bdt ...@@ -15,7 +15,7 @@ from . import bdt
from ..log import verbosity_option from ..log import verbosity_option
from ..build import next_build_number, conda_arch, should_skip_build, \ from ..build import next_build_number, conda_arch, should_skip_build, \
get_rendered_metadata, get_parsed_recipe, make_conda_config, \ get_rendered_metadata, get_parsed_recipe, make_conda_config, \
get_docserver_setup get_docserver_setup, get_env_directory
from ..constants import CONDA_BUILD_CONFIG, CONDA_RECIPE_APPEND, \ 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
...@@ -43,8 +43,7 @@ Examples: ...@@ -43,8 +43,7 @@ Examples:
@click.argument('recipe-dir', required=False, type=click.Path(file_okay=False, @click.argument('recipe-dir', required=False, type=click.Path(file_okay=False,
dir_okay=True, exists=True), nargs=-1) dir_okay=True, exists=True), nargs=-1)
@click.option('-p', '--python', default=('%d.%d' % sys.version_info[:2]), @click.option('-p', '--python', default=('%d.%d' % sys.version_info[:2]),
show_default=True, help='Version of python to build the ' \ show_default=True, help='Version of python to build the environment for')
'environment for [default: %(default)s]')
@click.option('-r', '--condarc', @click.option('-r', '--condarc',
help='Use custom conda configuration file instead of our own',) help='Use custom conda configuration file instead of our own',)
@click.option('-m', '--config', '--variant-config-files', show_default=True, @click.option('-m', '--config', '--variant-config-files', show_default=True,
...@@ -106,6 +105,10 @@ def build(recipe_dir, python, condarc, config, no_test, append_file, ...@@ -106,6 +105,10 @@ def build(recipe_dir, python, condarc, config, no_test, append_file,
'\n - '.join(channels + ['defaults'])) '\n - '.join(channels + ['defaults']))
condarc_options['channels'] = channels + ['defaults'] condarc_options['channels'] = channels + ['defaults']
# dump packages at 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, python, append_file, condarc_options) conda_config = make_conda_config(config, python, append_file, condarc_options)
set_environment('MATPLOTLIBRC', MATPLOTLIB_RCDIR, verbose=True) set_environment('MATPLOTLIBRC', MATPLOTLIB_RCDIR, verbose=True)
......
...@@ -243,9 +243,6 @@ def build(dry_run): ...@@ -243,9 +243,6 @@ def build(dry_run):
workdir = os.environ['CI_PROJECT_DIR'] workdir = os.environ['CI_PROJECT_DIR']
logger.info('os.environ["%s"] = %s', 'CI_PROJECT_DIR', workdir) logger.info('os.environ["%s"] = %s', 'CI_PROJECT_DIR', workdir)
name = os.environ['CI_PROJECT_NAME']
logger.info('os.environ["%s"] = %s', 'CI_PROJECT_NAME', name)
pyver = os.environ['PYTHON_VERSION'] pyver = os.environ['PYTHON_VERSION']
logger.info('os.environ["%s"] = %s', 'PYTHON_VERSION', pyver) logger.info('os.environ["%s"] = %s', 'PYTHON_VERSION', pyver)
...@@ -277,21 +274,43 @@ def build(dry_run): ...@@ -277,21 +274,43 @@ def build(dry_run):
'\n - '.join(channels + ['defaults'])) '\n - '.join(channels + ['defaults']))
condarc_options['channels'] = channels + ['defaults'] condarc_options['channels'] = channels + ['defaults']
# dump packages at conda_root
condarc_options['croot'] = os.path.join(prefix, 'conda-bld')
# create the build configuration # create the build configuration
logger.info('Merging conda configuration files...') logger.info('Merging conda configuration files...')
conda_config = make_conda_config(CONDA_BUILD_CONFIG, pyver, conda_config = make_conda_config(CONDA_BUILD_CONFIG, pyver,
CONDA_RECIPE_APPEND, condarc_options) CONDA_RECIPE_APPEND, condarc_options)
recipe_dir = os.path.join(workdir, 'conda')
if not os.path.exists(recipe_dir):
raise RuntimeError("The directory %s does not exist" % recipe_dir)
# pre-renders the recipe - figures out package name and version
metadata = get_rendered_metadata(recipe_dir, conda_config)
arch = conda_arch()
if should_skip_build(metadata):
logger.warn('Skipping UNSUPPORTED build of "%s" for py%s on %s',
d, python.replace('.',''), arch)
return 0
# converts the metadata output into parsed yaml and continues the process
rendered_recipe = get_parsed_recipe(metadata)
# retrieve the current build number for this build # retrieve the current build number for this build
build_number, _ = next_build_number(channels[0], name, version, pyver) build_number, _ = next_build_number(channels[0],
rendered_recipe['package']['name'],
rendered_recipe['package']['version'], python)
set_environment('BOB_BUILD_NUMBER', str(build_number), verbose=True) set_environment('BOB_BUILD_NUMBER', str(build_number), verbose=True)
# runs the build using the conda-build API # runs the build using the conda-build API
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',
name, version, pyver.replace('.',''), build_number, arch) rendered_recipe['package']['name'],
rendered_recipe['package']['version'], python.replace('.',''),
build_number, arch)
if not dry_run: if not dry_run:
conda_build.api.build(os.path.join(workdir, 'conda'), config=conda_config) conda_build.api.build(recipe_dir, config=conda_config)
git_clean_build(run_cmdline, arch) git_clean_build(run_cmdline, arch)
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