environment
flavor.psp.format_2025.environment
¶
Environment variable management for PSPF/2025 packages.
Handles platform-specific environment variables and layered environment processing.
Functions¶
apply_environment_layers
¶
apply_environment_layers(
base_env: dict[str, str],
runtime_env: dict[str, Any] | None = None,
workenv_env: dict[str, str] | None = None,
execution_env: dict[str, str] | None = None,
) -> dict[str, str]
Apply environment variable layers in order.
Layers (applied in order): 1. Runtime security layer (unset, pass, map, set operations) 2. Workenv layer (workenv-specific paths) 3. Execution layer (application-specific settings) 4. Platform layer (automatic, highest priority)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_env
|
dict[str, str]
|
Base environment variables |
required |
runtime_env
|
dict[str, Any] | None
|
Runtime security operations |
None
|
workenv_env
|
dict[str, str] | None
|
Workenv-specific variables |
None
|
execution_env
|
dict[str, str] | None
|
Execution-specific variables |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Final environment dictionary |
Source code in flavor/psp/format_2025/environment.py
process_runtime_env
¶
Process runtime environment configuration for PSPF/2025 packages.
This function modifies the environment map in-place, applying runtime environment operations in a specific order to ensure correct behavior. This implementation aligns with the Rust and Go implementations for cross-language consistency in the PSPF/2025 format.
Operations are processed in this order: 1. Analyze pass patterns - Build list of variables to preserve 2. unset - Remove specified variables (skipping those marked to preserve) 3. map - Rename variables (old_name -> new_name) 4. set - Set specific values (override or add new) 5. pass verification - Check that required variables/patterns exist
Pattern matching supports: - Exact matches: "PATH" matches only PATH - Glob patterns: "PYTHON_" matches PYTHON_HOME, PYTHON_PATH, etc. - Wildcard: "" matches all variables
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_map
|
dict[str, str]
|
Mutable environment variables dictionary to process. This dict is modified in-place. |
required |
runtime_env
|
dict[str, Any]
|
Runtime environment configuration containing: - pass: List of patterns for variables to preserve/require - unset: List of patterns for variables to remove - map: Dict of old_name -> new_name mappings - set: Dict of variable -> value assignments |
required |
Example
env = {"FOO": "bar", "BAZ": "qux", "TEMP": "123"} runtime = { ... "pass": ["FOO", "BA*"], ... "unset": ["TEMP"], ... "map": {"FOO": "NEW_FOO"}, ... "set": {"CUSTOM": "value"} ... } process_runtime_env(env, runtime)
Result:¶
Note
This function is called during package execution to prepare the environment for the packaged application. It ensures consistent environment handling across different platforms and launchers.
Source code in flavor/psp/format_2025/environment.py
set_platform_environment
¶
Set platform-specific environment variables.
These variables are always set and cannot be overridden by user configuration.
Variables set: - FLAVOR_OS: Operating system (darwin, linux, windows) - FLAVOR_ARCH: Architecture (amd64, arm64, x86, i386) - FLAVOR_PLATFORM: Combined OS_arch string - FLAVOR_OS_VERSION: OS version (if available) - FLAVOR_CPU_TYPE: CPU type/family (if available)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
dict[str, str]
|
Environment dictionary to update |
required |