Install & Compatibility
Where this runs
tested against v0.31.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.133s · 97.5MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 6.9s · import 0.127s · 97MB
95MB installed
● package 95MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
UefiBuilder
✓ from edk2toolext.environment.uefi_build import UefiBuilder
edk2_setup (command-line)
✓ python -m edk2toolext.invocables.edk2_setup
✗ from edk2toolext.invocables import edk2_setup
The `edk2_setup` tool is designed for command-line invocation via `python -m`, not direct programmatic import.
This quickstart demonstrates both the command-line usage of the `edk2_setup` tool (by showing its help) and the programmatic instantiation of the core `UefiBuilder` class. It sets up a minimal dummy EDK2 environment to ensure the code is runnable, but a full EDK2 build requires a properly configured external EDK2 source tree and toolchain.
import os
import tempfile
import shutil
from pathlib import Path
import subprocess
import sys
# --- Create a dummy EDK2 environment for demonstration ---
# In a real scenario, EDK2_PATH and WORKSPACE would point to
# your actual EDK2 source code and build workspace.
temp_dir = Path(tempfile.mkdtemp())
edk2_path = temp_dir / "edk2"
workspace_path = temp_dir / "MyWorkspace"
edk2_path.mkdir(exist_ok=True)
workspace_path.mkdir(exist_ok=True)
# Simulate minimal EDK2 structure needed for some checks
(edk2_path / "MdePkg").mkdir(exist_ok=True)
(edk2_path / "MdePkg" / "MdePkg.dsc").write_text("# Dummy DSC file")
(workspace_path / "MyPlatformPkg").mkdir(exist_ok=True)
(workspace_path / "MyPlatformPkg" / "MyPlatform.dsc").write_text("# Dummy Platform DSC file")
os.environ['EDK2_PATH'] = str(edk2_path)
os.environ['WORKSPACE'] = str(workspace_path)
try:
# --- 1. Demonstrate using the EDK2 setup tool (command-line) ---
# This tool helps download external dependencies for EDK2 builds.
print("\n--- Running EDK2 Setup Tool (displaying help) ---")
setup_result = subprocess.run(
[sys.executable, "-m", "edk2toolext.invocables.edk2_setup", "--help"],
capture_output=True, text=True, check=False
)
print("EDK2 Setup Tool Help Output (truncated):\n" + setup_result.stdout[:500] + "...")
if setup_result.returncode != 0:
print(f"Error running setup tool help: {setup_result.stderr}")
# --- 2. Demonstrate programmatic use of UefiBuilder ---
# UefiBuilder is a core class for orchestrating EDK2 builds.
print("\n--- Demonstrating programmatic import of UefiBuilder ---")
from edk2toolext.environment.uefi_build import UefiBuilder
builder_instance = UefiBuilder()
print(f"Successfully instantiated UefiBuilder: {builder_instance.__class__.__name__}")
print("Note: A real build would require valid EDK2 source, toolchains, ")
print("and potentially specific platform configuration files, which are ")
print("outside the scope of this minimal quickstart example.")
except ImportError as e:
print(f"Error importing EDK2 PyTool Extensions. Ensure it's installed: {e}")
except Exception as e:
print(f"An unexpected error occurred during quickstart: {e}")
finally:
# Clean up dummy environment
if temp_dir.exists():
shutil.rmtree(temp_dir)
print("\n--- Quickstart demonstration complete. --- ")
Errors
Common errors & fixes
EDK2_PATH environment variable not set or invalid.
The `EDK2_PATH` (and usually `WORKSPACE`) environment variable is either not defined or points to a directory that doesn't contain a valid EDK2 source tree as expected by the tools.
fixSet the `EDK2_PATH` and `WORKSPACE` environment variables to the root directory of your EDK2 source code before running any EDK2-PyTool-Extensions commands or scripts. Example: `export EDK2_PATH=/path/to/edk2/source` and `export WORKSPACE=/path/to/edk2/source` (Linux/macOS) or `set EDK2_PATH=C:\path\to\edk2\source` (Windows).
FileNotFoundError: [Errno 2] No such file or directory: 'nasm'
The EDK2 build process, orchestrated by this library, requires external executables (like `nasm`, `cl.exe`, `gcc`, `iasl`) that are not found in your system's PATH.
fixInstall the necessary EDK2 toolchain components (e.g., NASM assembler, Visual Studio Build Tools for MSVC, or GCC for GCC toolchain) and ensure their installation directory is added to your system's PATH environment variable.
AttributeError: module 'edk2toolext' has no attribute 'invocables'
This usually means you're trying to directly import a submodule like `edk2toolext.invocables.edk2_setup` programmatically when it's primarily designed for command-line invocation via `python -m`.
fixFor tools like `edk2_setup`, use the `python -m` command-line invocation (e.g., `python -m edk2toolext.invocables.edk2_setup`). For programmatic access, ensure you are importing specific classes like `UefiBuilder` from their correct paths (`from edk2toolext.environment.uefi_build import UefiBuilder`).
Upgrade
Version history
0.31.0latest on PyPI · released Mar 30, 2026
Audit
Dependencies
No dependency data recorded yet.