buildenv.loader =============== .. py:module:: buildenv.loader .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: buildenv.loader.VENV_OK buildenv.loader.NEWLINE_PER_TYPE buildenv.loader.logger buildenv.loader.project_path Classes ------- .. autoapisummary:: buildenv.loader.EnvContext buildenv.loader.BuildEnvLoader Functions --------- .. autoapisummary:: buildenv.loader.to_linux_path buildenv.loader.to_windows_path Module Contents --------------- .. py:data:: VENV_OK :value: 'venvOK' Valid venv tag file .. py:data:: NEWLINE_PER_TYPE Map of newline styles per file extension .. py:data:: logger Logger instance for buildenv module .. py:function:: 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) :param path: Path to be converted :return: Converted path, in Linux style .. py:function:: to_windows_path(path: pathlib.Path) -> str Turn provided path to a Windows style path. :param path: Path to be converted :return: Converted path, in Windows style .. py:class:: EnvContext(context: types.SimpleNamespace) Simple context class for a build env, providing some utility properties :param context: Environment context object, returned by EnvBuilder .. py:attribute:: context .. py:property:: root :type: pathlib.Path Path to environment root folder .. py:property:: bin_folder :type: pathlib.Path Path to bin folder in environment .. py:property:: executable :type: pathlib.Path Path to python executable in environment .. py:property:: activation_scripts_folder :type: pathlib.Path Path to activation scripts folder in environment .. py:class:: BuildEnvLoader(project_path: pathlib.Path) Wrapper to **buildenv** manager This wrapper mainly creates python venv (if not done yet) before delegating setup to :class:`buildenv.manager.BuildEnvManager`. Also provides configuration file (**buildenv.cfg**) reading facility. :param project_path: Path to project root directory .. py:attribute:: project_path .. py:attribute:: config_file .. py:attribute:: config_parser :value: None .. py:attribute:: is_ci .. py:attribute:: venv_folder .. py:attribute:: venv_path .. py:attribute:: requirements_file_pattern .. py:attribute:: prompt .. py:attribute:: look_up .. py:method:: 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). :param name: parameter name :param default: default value if parameter is not set :param resolve: resolve environment variables used in parameter value :return: parameter value .. py:method:: find_venv() -> Union[pathlib.Path, None] Find venv folder, in current project folder, or in parent ones :return: venv folder path, or None if no venv found .. py:property:: pip_args :type: str Additional arguments for "pip install" commands, read from **buildenv.cfg** project config file. .. py:property:: default_packages :type: list[str] List of packages installed by default when bootstrapping the buildenv .. py:property:: requirement_files :type: list[str] List of requirement files to be installed (deduced from requirements files pattern) .. py:method:: setup_venv(with_venv: pathlib.Path = None) -> EnvContext Prepare python environment builder, and create environment if it doesn't exist yet :param with_venv: Existing venv path (typically used for testing purpose) :return: Environment context object .. py:method:: setup(args: list[str]) -> int Prepare python venv if not done yet. Then invoke build env manager. :param args: Command line arguments :returns: Forwarded **buildenv** command return code .. py:data:: project_path