FABulous.FABulous_settings

FABulous settings management and environment configuration.

This module handles configuration settings for the FABulous FPGA framework, including tool paths, project settings, and environment variable management.

Classes

class FABulousSettings(_case_sensitive=None, _nested_model_default_partial_update=None, _env_prefix=None, _env_file=ENV_FILE_SENTINEL, _env_file_encoding=None, _env_ignore_empty=None, _env_nested_delimiter=None, _env_nested_max_split=None, _env_parse_none_str=None, _env_parse_enums=None, _cli_prog_name=None, _cli_parse_args=None, _cli_settings_source=None, _cli_parse_none_str=None, _cli_hide_none_type=None, _cli_avoid_json=None, _cli_enforce_required=None, _cli_use_class_docs_for_groups=None, _cli_exit_on_error=None, _cli_prefix=None, _cli_flag_prefix_char=None, _cli_implicit_flags=None, _cli_ignore_unknown_args=None, _cli_kebab_case=None, _cli_shortcuts=None, _secrets_dir=None, **values)[source]

Bases:

FABulous settings.

Tool paths are resolved lazily during validation so that environment variable setup (including PATH updates for oss-cad-suite) can occur beforehand.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Properties:

Methods:

Parameters:
  • _case_sensitive (bool | None)

  • _nested_model_default_partial_update (bool | None)

  • _env_prefix (str | None)

  • _env_file (pydantic_settings.sources.DotenvType | None)

  • _env_file_encoding (str | None)

  • _env_ignore_empty (bool | None)

  • _env_nested_delimiter (str | None)

  • _env_nested_max_split (int | None)

  • _env_parse_none_str (str | None)

  • _env_parse_enums (bool | None)

  • _cli_prog_name (str | None)

  • _cli_parse_args (bool | list[str] | tuple[str, Ellipsis] | None)

  • _cli_settings_source (CliSettingsSource[Any] | None)

  • _cli_parse_none_str (str | None)

  • _cli_hide_none_type (bool | None)

  • _cli_avoid_json (bool | None)

  • _cli_enforce_required (bool | None)

  • _cli_use_class_docs_for_groups (bool | None)

  • _cli_exit_on_error (bool | None)

  • _cli_prefix (str | None)

  • _cli_flag_prefix_char (str | None)

  • _cli_implicit_flags (bool | None)

  • _cli_ignore_unknown_args (bool | None)

  • _cli_kebab_case (bool | Literal['all', 'no_enums'] | None)

  • _cli_shortcuts (Mapping[str, str | list[str]] | None)

  • _secrets_dir (pydantic_settings.sources.PathType | None)

  • values (Any)

ensure_user_config_dir(value)[source]

Ensure user config directory exists, creating if necessary.

Parameters:

value (Path | None)

Return type:

Path | None

is_valid_project_dir(value)[source]

Check if project_dir is a valid directory.

Parameters:

value (Path | None)

Return type:

Path | None

parse_models_pack(value, info)[source]

Validate and normalise models_pack path based on project language.

Uses already-validated proj_lang from info.data when available. Accepts None / empty string to mean unset.

Parameters:
Return type:

Path | None

parse_oss_cad_suite_path(value)[source]

Parse oss-cad-suite path and publish it to $PATH.

Parses the oss-cad-suite path from env var and publishes it to PATH before the init of other tools, that then can be found in PATH.

Parameters:

value (Path | str | None)

Return type:

Path | None

parse_proj_lang(value)[source]

Parse project language from string or HDLType enum.

Parameters:

value (str | HDLType)

Return type:

str | HDLType

parse_version_str(value)[source]

Parse version from string or Version object.

Parameters:

value (str | packaging.version.Version)

Return type:

packaging.version.Version

resolve_tool_paths(value, info)[source]

Resolve tool paths by checking if tools are available in PATH.

This method is used as a field validator to automatically resolve tool paths during settings initialization. If a tool path is not explicitly provided, it searches for the tool in the system PATH.

Parameters:
  • value (Path | str | None) – The explicitly provided tool path, if any.

  • info (ValidationInfo) – Validation context containing field information.

Returns:

The resolved path to the tool if found, tool name otherwise.

Return type:

Path | str

Notes

This method logs a warning if a tool is not found in PATH, as some features may be unavailable without the tool.

validate_proj_lang(value)[source]

Validate and normalise the project language to HDLType enum.

Parameters:

value (str | HDLType)

Return type:

HDLType

Functions

add_var_to_global_env(key, value)[source]
Parameters:
Return type:

None

Add or update a key-value pair to the global .env file.

param key:

The environment variable key to add or update.

type key:

str

param value:

The value to set for the environment variable.

type value:

str

get_context()[source]
Return type:

FABulousSettings

Get the global FABulous context.

returns:

The current FABulousSettings instance

rtype:

FABulousSettings

init_context(project_dir=None, global_dot_env=None, project_dot_env=None, api_mode=False)[source]
Parameters:
  • project_dir (Path | None)

  • global_dot_env (Path | None)

  • project_dot_env (Path | None)

  • api_mode (bool)

Return type:

FABulousSettings

Initialize the global FABulous context with settings.

This function gathers .env files and lets the pydantic-settings system handle project directory resolution.

param project_dir:

Project directory path (if None, uses cwd)

type project_dir:

Path | None

param global_dot_env:

Path to a global .env file (if any)

type global_dot_env:

Path | None

param project_dot_env:

Path to a project-specific .env file (if any)

type project_dot_env:

Path | None

param api_mode:

If True, skips all validation for API mode

type api_mode:

bool

returns:

The initialized FABulousSettings instance

rtype:

FABulousSettings

reset_context()[source]
Return type:

None

Reset the global context (primarily for testing).

Module Attributes

FAB_USER_CONFIG_DIR[source]