diff --git a/bob/devtools/scripts/build.py b/bob/devtools/scripts/build.py index 9d2a965922c8c85006b6ca2956c14b3fb1c76aa7..9a79a64b6f1d7ce9e4613b0282446a590fb9059c 100644 --- a/bob/devtools/scripts/build.py +++ b/bob/devtools/scripts/build.py @@ -86,8 +86,8 @@ def build(recipe_dir, python, condarc, config, no_test, append_file, # if we are in a dry-run mode, let's let it be known if dry_run: - logger.warn('!!!! DRY RUN MODE !!!!') - logger.warn('Nothing will be really built') + logger.warn('!!!! DRY RUN MODE !!!!') + logger.warn('Nothing will be really built') recipe_dir = recipe_dir or [os.path.join(os.path.realpath('.'), 'conda')] diff --git a/bob/devtools/scripts/ci.py b/bob/devtools/scripts/ci.py index cdeb3c2a8dd156e8b8b8d37209323330a5fa83a8..6023c4b6af7fd13c948f50d3b9f063a903caf095 100644 --- a/bob/devtools/scripts/ci.py +++ b/bob/devtools/scripts/ci.py @@ -420,10 +420,16 @@ Examples: help='Only goes through the actions, but does not execute them ' \ '(combine with the verbosity flags - e.g. ``-vvv``) to enable ' \ 'printing to help you understand what will be done') +@click.option( + '-r', + '--recipe-dir', + default=os.path.join(os.path.realpath(os.curdir), 'conda'), + help="Custom recipe folder for build. Useful for debugging." +) @verbosity_option() @bdt.raise_on_error @click.pass_context -def build(ctx, dry_run): +def build(ctx, dry_run, recipe_dir): """Builds packages This command builds packages in the CI infrastructure. It is **not** meant @@ -436,9 +442,7 @@ def build(ctx, dry_run): group = 'bob' # Use custom variants and append files if available on recipe-dir - recipe_dir = os.path.join(os.path.realpath(os.curdir), 'conda') - - condarc = select_user_condarc(paths=[recipe, os.curdir], + condarc = select_user_condarc(paths=[recipe_dir, os.curdir], branch=os.environ.get('CI_COMMIT_REF_NAME')) if condarc is not None: logger.info('Condarc configuration file: %s', condarc) diff --git a/bob/devtools/scripts/local.py b/bob/devtools/scripts/local.py index 2eca76070ddb62b531042cde12d5b85bb1b8598a..8124fd98013bc72e0923b243ba76286896407bca 100644 --- a/bob/devtools/scripts/local.py +++ b/bob/devtools/scripts/local.py @@ -15,76 +15,152 @@ from click_plugins import with_plugins from . import bdt from . import ci -from ..constants import SERVER, CONDA_BUILD_CONFIG, CONDA_RECIPE_APPEND, \ - WEBDAV_PATHS, BASE_CONDARC +from ..constants import ( + SERVER, + CONDA_BUILD_CONFIG, + CONDA_RECIPE_APPEND, + WEBDAV_PATHS, + BASE_CONDARC, +) from ..deploy import deploy_conda_package, deploy_documentation from ..ci import read_packages, comment_cleanup, uniq from ..log import verbosity_option, get_logger, echo_normal + logger = get_logger(__name__) -def set_up_environment_variables(python, name_space, project_dir='.', project_visibility='public'): - """ +def set_up_environment_variables( + python, name_space, project_dir=".", project_visibility="public" +): + """ This function sets up the proper environment variables when user wants to run the commands usually run on ci locally """ - os.environ['CI_JOB_TOKEN'] = gitlab.Gitlab.from_config('idiap').private_token - os.environ['CI_PROJECT_DIR'] = project_dir - os.environ['CI_PROJECT_NAMESPACE'] = name_space - os.environ['CI_PROJECT_VISIBILITY'] = project_visibility - os.environ['PYTHON_VERSION']= python + os.environ["CI_JOB_TOKEN"] = gitlab.Gitlab.from_config("idiap").private_token + os.environ["CI_PROJECT_DIR"] = project_dir + os.environ["CI_PROJECT_NAMESPACE"] = name_space + os.environ["CI_PROJECT_VISIBILITY"] = project_visibility + os.environ["PYTHON_VERSION"] = python - -@with_plugins(pkg_resources.iter_entry_points('bdt.local.cli')) +@with_plugins(pkg_resources.iter_entry_points("bdt.local.cli")) @click.group(cls=bdt.AliasedGroup) def local(): - """Commands for building packages and handling certain activities locally + """Commands for building packages and handling certain activities locally it requires a proper set up for ~/.python-gitlab.cfg Commands defined here can be run in your own installation. """ - pass + pass -@local.command(epilog=''' +@local.command( + epilog=""" Examples: 1. Prepares the docs locally: $ bdt local docs -vv requirements.txt -''') -@click.argument('requirement', required=True, type=click.Path(file_okay=True, - dir_okay=False, exists=True), nargs=1) -@click.option('-d', '--dry-run/--no-dry-run', default=False, - help='Only goes through the actions, but does not execute them ' \ - '(combine with the verbosity flags - e.g. ``-vvv``) to enable ' \ - 'printing to help you understand what will be done') -@click.option('-p', '--python', default=('%d.%d' % sys.version_info[:2]), - show_default=True, help='Version of python to build the environment for') -@click.option('-g', '--group', show_default=True, default='bob', - help='Group of packages (gitlab namespace) this package belongs to') +""" +) +@click.argument( + "requirement", + required=True, + type=click.Path(file_okay=True, dir_okay=False, exists=True), + nargs=1, +) +@click.option( + "-d", + "--dry-run/--no-dry-run", + default=False, + help="Only goes through the actions, but does not execute them " + "(combine with the verbosity flags - e.g. ``-vvv``) to enable " + "printing to help you understand what will be done", +) +@click.option( + "-p", + "--python", + default=("%d.%d" % sys.version_info[:2]), + show_default=True, + help="Version of python to build the environment for", +) +@click.option( + "-g", + "--group", + show_default=True, + default="bob", + help="Group of packages (gitlab namespace) this package belongs to", +) @verbosity_option() @bdt.raise_on_error @click.pass_context def docs(ctx, requirement, dry_run, python, group): - """Prepares documentation build + """Prepares documentation build This command: \b - + 1. Clones all the necessary packages necessary to build the bob/beat documentation - + \b 2. Generates the `extra-intersphinx.txt` and `nitpick-exceptions.txt` file - + \b """ - set_up_environment_variables(python=python, name_space=group) + set_up_environment_variables(python=python, name_space=group) + + ctx.invoke(ci.docs, requirement=requirement, dry_run=dry_run) + + +@local.command( + epilog=""" +Examples: + + 1. Runs the CI build steps locally: + + $ bdt local build -vv + +""" +) +@click.option( + "-d", + "--dry-run/--no-dry-run", + default=False, + help="Only goes through the actions, but does not execute them " + "(combine with the verbosity flags - e.g. ``-vvv``) to enable " + "printing to help you understand what will be done", +) +@click.option( + '-r', + '--recipe-dir', + default=os.path.join(os.path.realpath(os.curdir), 'conda'), + help="Custom recipe folder for build." +) +@click.option( + "-p", + "--python", + default=("%d.%d" % sys.version_info[:2]), + show_default=True, + help="Version of python to build the environment for", +) +@click.option( + "-g", + "--group", + show_default=True, + default="bob", + help="Group of packages (gitlab namespace) this package belongs to", +) +@verbosity_option() +@bdt.raise_on_error +@click.pass_context +def build(ctx, dry_run, recipe_dir, python, group): + """Run the CI build step locally + """ + set_up_environment_variables(python=python, name_space=group) - ctx.invoke(ci.docs, requirement=requirement, dry_run=dry_run) + ctx.invoke(ci.build, dry_run=dry_run, recipe_dir=recipe_dir) diff --git a/setup.py b/setup.py index dc8c28f99aa4472c1802245cabda9eac81f92fc4..386a9455832d0e06fc269b401bfb3c3d06177d99 100644 --- a/setup.py +++ b/setup.py @@ -80,11 +80,12 @@ setup( 'readme = bob.devtools.scripts.ci:readme', 'pypi = bob.devtools.scripts.ci:pypi', 'nightlies = bob.devtools.scripts.ci:nightlies', - 'docs = bob.devtools.scripts.ci:docs', + 'docs = bob.devtools.scripts.ci:docs', ], 'bdt.local.cli': [ - 'docs = bob.devtools.scripts.local:docs', + 'docs = bob.devtools.scripts.local:docs', + 'build = bob.devtools.scripts.local:build', ], },