buildenv.loader

Python module for loading script.

This module is standalone (i.e. it doesn’t have any dependencies out of the raw python SDK) and is designed to be:

  • copied in project root folder

  • kept in source control, so that the script is ready to run just after project clone

Attributes

VENV_OK

Valid venv tag file

NEWLINE_PER_TYPE

Map of newline styles per file extension

logger

Logger instance for buildenv module

project_path

Classes

EnvContext

Simple context class for a build env, providing some utility properties

BuildEnvLoader

Wrapper to buildenv manager

Functions

to_linux_path(→ str)

Turn provided path to a Linux style path.

to_windows_path(→ str)

Turn provided path to a Windows style path.

Module Contents

buildenv.loader.VENV_OK = 'venvOK'

Valid venv tag file

buildenv.loader.NEWLINE_PER_TYPE

Map of newline styles per file extension

buildenv.loader.logger

Logger instance for buildenv module

buildenv.loader.to_linux_path(path: pathlib.Path) str

Turn provided path to a Linux style path. On Windows, this means turning drive “X:” to “/x/” format (git-bash style path)

Parameters:

path – Path to be converted

Returns:

Converted path, in Linux style

buildenv.loader.to_windows_path(path: pathlib.Path) str

Turn provided path to a Windows style path.

Parameters:

path – Path to be converted

Returns:

Converted path, in Windows style

class buildenv.loader.EnvContext(context: types.SimpleNamespace)

Simple context class for a build env, providing some utility properties

Parameters:

context – Environment context object, returned by EnvBuilder

context
property root: pathlib.Path

Path to environment root folder

property bin_folder: pathlib.Path

Path to bin folder in environment

property executable: pathlib.Path

Path to python executable in environment

property activation_scripts_folder: pathlib.Path

Path to activation scripts folder in environment

class buildenv.loader.BuildEnvLoader(project_path: pathlib.Path)

Wrapper to buildenv manager

This wrapper mainly creates python venv (if not done yet) before delegating setup to buildenv.manager.BuildEnvManager. Also provides configuration file (buildenv.cfg) reading facility.

Parameters:

project_path – Path to project root directory

project_path
config_file
config_parser = None
is_ci
venv_folder
venv_path
requirements_file
prompt
look_up
read_config(name: str, default: str, resolve: bool = False) str

Read configuration parameter from config file (buildenv.cfg).

Value is read according to the current profile: [local] or [ci] (if CI env var is defined and not empty). Note that if a parameter is not defined in [ci] profile, it will be defaulted to value in [local] profile, if any (otherwise provided default will be used).

Parameters:
  • name – parameter name

  • default – default value if parameter is not set

  • resolve – resolve environment variables used in parameter value

Returns:

parameter value

find_venv() pathlib.Path | None

Find venv folder, in current project folder, or in parent ones

Returns:

venv folder path, or None if no venv found

property pip_args: str

Additional arguments for “pip install” commands, read from buildenv.cfg project config file.

property default_packages: List[str]

List of packages installed by default when bootstrapping the buildenv

setup_venv(with_venv: pathlib.Path = None) EnvContext

Prepare python environment builder, and create environment if it doesn’t exist yet

Parameters:

with_venv – Existing venv path (typically used for testing purpose)

Returns:

Environment context object

setup(args: List[str]) int

Prepare python venv if not done yet. Then invoke build env manager.

Parameters:

args – Command line arguments

Returns:

Forwarded buildenv command return code

buildenv.loader.project_path