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

Merge branch 'user-condarc' into 'master'

Allow builds to define their custom condarc to be used

See merge request !82
parents 2db104b3 759e9305
Branches
Tags
1 merge request!82Allow builds to define their custom condarc to be used
Pipeline #32333 passed
...@@ -18,3 +18,4 @@ build ...@@ -18,3 +18,4 @@ build
record.txt record.txt
miniconda.sh miniconda.sh
miniconda/ miniconda/
.DS_Store
...@@ -195,3 +195,13 @@ def select_conda_recipe_append(paths, branch): ...@@ -195,3 +195,13 @@ def select_conda_recipe_append(paths, branch):
from .constants import CONDA_RECIPE_APPEND as default from .constants import CONDA_RECIPE_APPEND as default
return select_build_file(default, paths, branch) or default return select_build_file(default, paths, branch) or default
def select_user_condarc(paths, branch):
'''Selects the user condarc file to read (if any)
See :py:func:`select_build_file` for implementation details. If no recipe
condarc is found by :py:func:`select_build_file`, then returns ``None``.
'''
return select_build_file('condarc', paths, branch)
...@@ -14,7 +14,7 @@ from . import bdt ...@@ -14,7 +14,7 @@ from . import bdt
from ..constants import SERVER, WEBDAV_PATHS, BASE_CONDARC from ..constants import SERVER, WEBDAV_PATHS, BASE_CONDARC
from ..deploy import deploy_conda_package, deploy_documentation from ..deploy import deploy_conda_package, deploy_documentation
from ..ci import read_packages, comment_cleanup, uniq, \ from ..ci import read_packages, comment_cleanup, uniq, \
select_conda_build_config, select_conda_recipe_append select_conda_build_config, select_conda_recipe_append, select_user_condarc
from ..log import verbosity_option, get_logger, echo_normal from ..log import verbosity_option, get_logger, echo_normal
logger = get_logger(__name__) logger = get_logger(__name__)
...@@ -278,7 +278,11 @@ def base_build(order, group, python, dry_run): ...@@ -278,7 +278,11 @@ def base_build(order, group, python, dry_run):
this context. this context.
""" """
condarc = os.path.join(os.environ['CONDA_ROOT'], 'condarc') condarc = select_user_condarc(paths=[recipe, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
condarc = condarc or os.path.join(os.environ['CONDA_ROOT'], 'condarc')
if os.path.exists(condarc): if os.path.exists(condarc):
logger.info('Loading (this build\'s) CONDARC file from %s...', condarc) logger.info('Loading (this build\'s) CONDARC file from %s...', condarc)
with open(condarc, 'rb') as f: with open(condarc, 'rb') as f:
...@@ -375,6 +379,11 @@ def test(ctx, dry_run): ...@@ -375,6 +379,11 @@ def test(ctx, dry_run):
# Use custom variants and append files if available on recipe-dir # Use custom variants and append files if available on recipe-dir
recipe_dir = os.path.join(os.path.realpath(os.curdir), 'conda') recipe_dir = os.path.join(os.path.realpath(os.curdir), 'conda')
condarc = select_user_condarc(paths=[recipe, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
if condarc is not None:
logger.info('Condarc configuration file: %s', condarc)
variants_file = select_conda_build_config(paths=[recipe_dir, os.curdir], variants_file = select_conda_build_config(paths=[recipe_dir, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME')) branch=os.environ.get('CI_COMMIT_REF_NAME'))
logger.info('Conda build configuration file: %s', variants_file) logger.info('Conda build configuration file: %s', variants_file)
...@@ -387,7 +396,7 @@ def test(ctx, dry_run): ...@@ -387,7 +396,7 @@ def test(ctx, dry_run):
ctx.invoke(test, ctx.invoke(test,
package = glob.glob(os.path.join(os.environ['CONDA_ROOT'], 'conda-bld', package = glob.glob(os.path.join(os.environ['CONDA_ROOT'], 'conda-bld',
'*', os.environ['CI_PROJECT_NAME'] + '*.tar.bz2')), '*', os.environ['CI_PROJECT_NAME'] + '*.tar.bz2')),
condarc=None, #custom build configuration condarc=condarc,
config=variants_file, config=variants_file,
append_file=append_file, append_file=append_file,
server=SERVER, server=SERVER,
...@@ -429,6 +438,11 @@ def build(ctx, dry_run): ...@@ -429,6 +438,11 @@ def build(ctx, dry_run):
# Use custom variants and append files if available on recipe-dir # Use custom variants and append files if available on recipe-dir
recipe_dir = os.path.join(os.path.realpath(os.curdir), 'conda') recipe_dir = os.path.join(os.path.realpath(os.curdir), 'conda')
condarc = select_user_condarc(paths=[recipe, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
if condarc is not None:
logger.info('Condarc configuration file: %s', condarc)
variants_file = select_conda_build_config(paths=[recipe_dir, os.curdir], variants_file = select_conda_build_config(paths=[recipe_dir, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME')) branch=os.environ.get('CI_COMMIT_REF_NAME'))
logger.info('Conda build configuration file: %s', variants_file) logger.info('Conda build configuration file: %s', variants_file)
...@@ -441,7 +455,7 @@ def build(ctx, dry_run): ...@@ -441,7 +455,7 @@ def build(ctx, dry_run):
ctx.invoke(build, ctx.invoke(build,
recipe_dir=[recipe_dir], recipe_dir=[recipe_dir],
python=os.environ['PYTHON_VERSION'], #python version python=os.environ['PYTHON_VERSION'], #python version
condarc=None, #custom build configuration condarc=condarc,
config=variants_file, config=variants_file,
no_test=False, no_test=False,
append_file=append_file, append_file=append_file,
...@@ -552,6 +566,11 @@ def nightlies(ctx, order, dry_run): ...@@ -552,6 +566,11 @@ def nightlies(ctx, order, dry_run):
# Use custom variants and append files if available on recipe-dir # Use custom variants and append files if available on recipe-dir
recipe_dir = os.path.join(clone_to, 'conda') recipe_dir = os.path.join(clone_to, 'conda')
condarc = select_user_condarc(paths=[recipe, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
if condarc is not None:
logger.info('Condarc configuration file: %s', condarc)
variants_file = select_conda_build_config(paths=[recipe_dir, os.curdir], variants_file = select_conda_build_config(paths=[recipe_dir, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME')) branch=os.environ.get('CI_COMMIT_REF_NAME'))
logger.info('Conda build configuration file: %s', variants_file) logger.info('Conda build configuration file: %s', variants_file)
...@@ -563,7 +582,7 @@ def nightlies(ctx, order, dry_run): ...@@ -563,7 +582,7 @@ def nightlies(ctx, order, dry_run):
ctx.invoke(build, ctx.invoke(build,
recipe_dir=[recipe_dir], recipe_dir=[recipe_dir],
python=os.environ['PYTHON_VERSION'], #python version python=os.environ['PYTHON_VERSION'], #python version
condarc=None, #custom build configuration condarc=condarc,
config=variants_file, config=variants_file,
no_test=False, no_test=False,
append_file=append_file, append_file=append_file,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment