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

[bootstrap] make set_environment use logger in a simpler way...

parent a6959ee5
No related branches found
No related tags found
No related merge requests found
Pipeline #26166 passed
......@@ -46,7 +46,7 @@ import logging
logger = logging.getLogger(__name__)
def set_environment(name, value, env=os.environ, verbose=False):
def set_environment(name, value, env=os.environ):
'''Function to setup the environment variable and print debug message
Args:
......@@ -54,14 +54,10 @@ def set_environment(name, value, env=os.environ, verbose=False):
name: The name of the environment variable to set
value: The value to set the environment variable to
env: Optional environment (dictionary) where to set the variable at
verbose: Increases the verbosity of variable reporting
'''
env[name] = value
logat = logger.debug
if verbose:
logat = logger.info
logat('environ["%s"] = %s', name, value)
logger.info('environ["%s"] = %s', name, value)
return value
......
......@@ -451,15 +451,13 @@ if __name__ == '__main__':
bootstrap.setup_logger(logger, args.verbose)
VERB = (verbose >= 2)
bootstrap.set_environment('DOCSERVER', bootstrap._SERVER, verbose=VERB)
bootstrap.set_environment('LANG', 'en_US.UTF-8', verbose=VERB)
bootstrap.set_environment('LC_ALL', os.environ['LANG'], verbose=VERB)
bootstrap.set_environment('DOCSERVER', bootstrap._SERVER)
bootstrap.set_environment('LANG', 'en_US.UTF-8')
bootstrap.set_environment('LC_ALL', os.environ['LANG'])
# get information about the version of the package being built
version, is_prerelease = check_version(args.work_dir, args.tag)
bootstrap.set_environment('BOB_PACKAGE_VERSION', version, verbose=VERB)
bootstrap.set_environment('BOB_PACKAGE_VERSION', version)
# create the build configuration
conda_build_config = os.path.join(mydir, 'data', 'conda_build_config.yaml')
......@@ -489,8 +487,7 @@ if __name__ == '__main__':
# retrieve the current build number for this build
build_number, _ = next_build_number(channels[0], args.name, version,
args.python_version)
bootstrap.set_environment('BOB_BUILD_NUMBER', str(build_number),
verbose=VERB)
bootstrap.set_environment('BOB_BUILD_NUMBER', str(build_number))
# runs the build using the conda-build API
arch = conda_arch()
......@@ -500,4 +497,4 @@ if __name__ == '__main__':
conda_build.api.build(os.path.join(args.work_dir, 'conda'),
config=conda_config)
git_clean_build(bootstrap.run_cmdline, verbose=VERB)
git_clean_build(bootstrap.run_cmdline, verbose=(args.verbose >= 2))
......@@ -114,14 +114,14 @@ def build(recipe_dir, python, condarc, config, no_test, append_file,
conda_config = make_conda_config(config, python, append_file,
condarc_options)
set_environment('MATPLOTLIBRC', MATPLOTLIB_RCDIR, verbose=True)
set_environment('MATPLOTLIBRC', MATPLOTLIB_RCDIR)
# setup BOB_DOCUMENTATION_SERVER environment variable (used for bob.extension
# and derived documentation building via Sphinx)
set_environment('DOCSERVER', server, verbose=True)
set_environment('DOCSERVER', server)
doc_urls = get_docserver_setup(public=(not private), stable=stable,
server=server, intranet=ci)
set_environment('BOB_DOCUMENTATION_SERVER', doc_urls, verbose=True)
set_environment('BOB_DOCUMENTATION_SERVER', doc_urls)
for d in recipe_dir:
......@@ -131,7 +131,7 @@ def build(recipe_dir, python, condarc, config, no_test, append_file,
version_candidate = os.path.join(d, '..', 'version.txt')
if os.path.exists(version_candidate):
version = open(version_candidate).read().rstrip()
set_environment('BOB_PACKAGE_VERSION', version, verbose=True)
set_environment('BOB_PACKAGE_VERSION', version)
# pre-renders the recipe - figures out package name and version
metadata = get_rendered_metadata(d, conda_config)
......@@ -151,7 +151,7 @@ def build(recipe_dir, python, condarc, config, no_test, append_file,
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))
logger.info('Building %s-%s-py%s (build: %d) for %s',
rendered_recipe['package']['name'],
......
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