Skip to content
Snippets Groups Projects
Commit da439745 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Merge branch 'fix-local-for-ci-docs' into 'master'

added command to generate documentations locally

See merge request !60
parents 469b4e0f 0cedb089
No related branches found
No related tags found
1 merge request!60added command to generate documentations locally
Pipeline #31537 failed
...@@ -651,9 +651,14 @@ def docs(ctx, requirement, dry_run): ...@@ -651,9 +651,14 @@ def docs(ctx, requirement, dry_run):
"""Prepares documentation build """Prepares documentation build
This command: This command:
\b
1. Clones all the necessary packages necessary to build the bob/beat 1. Clones all the necessary packages necessary to build the bob/beat
documentation documentation
\b
2. Generates the `extra-intersphinx.txt` and `nitpick-exceptions.txt` file 2. Generates the `extra-intersphinx.txt` and `nitpick-exceptions.txt` file
\b
This command is supposed to be run **instead** of `bdt ci build...` This command is supposed to be run **instead** of `bdt ci build...`
......
#!/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)
...@@ -55,6 +55,7 @@ setup( ...@@ -55,6 +55,7 @@ setup(
'test = bob.devtools.scripts.test:test', 'test = bob.devtools.scripts.test:test',
'caupdate = bob.devtools.scripts.caupdate:caupdate', 'caupdate = bob.devtools.scripts.caupdate:caupdate',
'ci = bob.devtools.scripts.ci:ci', 'ci = bob.devtools.scripts.ci:ci',
'local = bob.devtools.scripts.local:local',
'gitlab = bob.devtools.scripts.gitlab:gitlab', 'gitlab = bob.devtools.scripts.gitlab:gitlab',
], ],
...@@ -82,6 +83,10 @@ setup( ...@@ -82,6 +83,10 @@ setup(
'docs = bob.devtools.scripts.ci:docs', 'docs = bob.devtools.scripts.ci:docs',
], ],
'bdt.local.cli': [
'docs = bob.devtools.scripts.local:docs',
],
}, },
classifiers=[ classifiers=[
'Framework :: Bob', 'Framework :: Bob',
......
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