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.

Attributes

Classes

FABulousSettings

FABulous settings.

Functions

add_var_to_global_env(key, value)

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

get_context()

Get the global FABulous context.

init_context([project_dir, global_dot_env, ...])

Initialize the global FABulous context with settings.

is_pdk_config_set()

Check if PDK root and PDK name are configured in the global context.

reset_context()

Reset the global context (primarily for testing).

Module Contents

FAB_USER_CONFIG_DIR[source]

FABulousSettings

FABulousSettings(_case_sensitive = None, _nested_model_default_partial_update = None, _env_prefix = None, _env_prefix_target = 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, _build_sources = None, **values)   :module:

Inheritance: → FABulousSettings

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.

check_pdk      :module:

Check if PDK_root and PDK are set correctly.

When a supported PDK family is configured and pdk_hash has not been provided, this validator resolves the recommended hash from librelane and auto-installs/activates the PDK via ciel.

Validation rules

  1. Both pdk and pdk_root are None -> warn, return (GDS unavailable)

  2. pdk_root set but pdk is None -> raise ValueError

  3. pdk set, pdk_root None, ciel family -> auto-resolve pdk_root

  4. pdk set, pdk_root None, not ciel -> raise ValueError

  5. Both set, not ciel family -> info log + return

  6. Both set, ciel family -> hash resolution + enable

    ensure_user_config_dirvalue      :module:

Ensure user config directory exists, creating if necessary.

is_valid_project_dirvalue      :module:

Check if project_dir is a valid directory.

parse_models_packvalue, info      :module:

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.

parse_oss_cad_suite_pathvalue      :module:

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.

parse_proj_langvalue      :module:

Parse project language from string or HDLType enum.

parse_version_strvalue      :module:

Parse version from string or Version object.

resolve_tool_pathsvalue, info      :module:

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.

param value:

The explicitly provided tool path, if any.

type value:

Path | str | None

param info:

Validation context containing field information.

type info:

ValidationInfo

returns:

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

rtype:

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_langvalue      :module:

Validate and normalise the project language to HDLType enum.

add_var_to_global_env(key, value)[source]

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

Parameters:
  • key (str) – The environment variable key to add or update.

  • value (str) – The value to set for the environment variable.

Return type:

None

get_context()[source]

Get the global FABulous context.

Returns:

The current FABulousSettings instance

Return type:

FABulousSettings

init_context(project_dir=None, global_dot_env=None, project_dot_env=None, api_mode=False)[source]

Initialize the global FABulous context with settings.

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

Parameters:
  • project_dir (Path | None) – Project directory path (if None, uses cwd)

  • global_dot_env (Path | None) – Path to a global .env file (if any)

  • project_dot_env (Path | None) – Path to a project-specific .env file (if any)

  • api_mode (bool) – If True, skips all validation for API mode

Returns:

The initialized FABulousSettings instance

Return type:

FABulousSettings

is_pdk_config_set()[source]

Check if PDK root and PDK name are configured in the global context.

Returns:

True if both pdk and pdk_root are set in the global context, False otherwise.

Return type:

bool

reset_context()[source]

Reset the global context (primarily for testing).

Return type:

None