diff --git a/bob/devtools/scripts/ci.py b/bob/devtools/scripts/ci.py index e108a9383183921e9e739ea9a8a9a2df36a954e8..7abbef3bc08ea3d3979534ae834e214d5270eeed 100644 --- a/bob/devtools/scripts/ci.py +++ b/bob/devtools/scripts/ci.py @@ -651,9 +651,14 @@ def docs(ctx, requirement, dry_run): """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 This command is supposed to be run **instead** of `bdt ci build...` diff --git a/bob/devtools/scripts/local.py b/bob/devtools/scripts/local.py new file mode 100644 index 0000000000000000000000000000000000000000..2eca76070ddb62b531042cde12d5b85bb1b8598a --- /dev/null +++ b/bob/devtools/scripts/local.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python + +import os +import sys +import re +import glob +import shutil + +import gitlab + +import yaml +import click +import pkg_resources +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 ..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'): + """ + 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 + + + +@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 + it requires a proper set up for ~/.python-gitlab.cfg + + Commands defined here can be run in your own installation. + """ + pass + + +@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') +@verbosity_option() +@bdt.raise_on_error +@click.pass_context +def docs(ctx, requirement, dry_run, python, group): + """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) + + ctx.invoke(ci.docs, requirement=requirement, dry_run=dry_run) diff --git a/setup.py b/setup.py index 03be32f07c606752586dab4300d9d059b1130e3a..dc8c28f99aa4472c1802245cabda9eac81f92fc4 100644 --- a/setup.py +++ b/setup.py @@ -55,6 +55,7 @@ setup( 'test = bob.devtools.scripts.test:test', 'caupdate = bob.devtools.scripts.caupdate:caupdate', 'ci = bob.devtools.scripts.ci:ci', + 'local = bob.devtools.scripts.local:local', 'gitlab = bob.devtools.scripts.gitlab:gitlab', ], @@ -82,6 +83,10 @@ setup( 'docs = bob.devtools.scripts.ci:docs', ], + 'bdt.local.cli': [ + 'docs = bob.devtools.scripts.local:docs', + ], + }, classifiers=[ 'Framework :: Bob',