Registry / devops / edk2-pytool-library

edk2-pytool-library

JSON →
library0.23.13pypypiunverified

The edk2-pytool-library is a Tianocore-maintained Python library, currently at version 0.23.13, that supports UEFI EDK2 firmware development. It provides modules for tasks such as parsing EDK2-specific file types, encoding/decoding UEFI binary structures, wrapping system CLI tools (e.g., signtool), and offering general utilities like logging and path resolution. Its intent is to provide reusable python code and is typically consumed by other tools and scripts, rather than directly by end-users via command-line interfaces. It is released on an ongoing basis, with minor releases for each merged pull request.

pip install --upgrade edk2-pytool-library
INSTALL
IMPORT
SIG · EDK2-PYTOOL-LIBRAR
E
edk2-pytool-library
devopspythonv0.23.13
Install
5.5s avg
Import
Disk
76MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.23.13 · 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
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 82.5MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 5.5s · import 0.000s · 81MB
76MB installed
● package 76MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Edk2Path
from edk2toollib.path_utilities import Edk2Path
PrintFileData
from edk2toollib.utility_functions import PrintFileData

This quickstart demonstrates how to import and use the `Edk2Path` class from `edk2toollib.path_utilities` to manage EDK2 file paths. It sets up a temporary workspace and package structure to showcase how an absolute path can be converted into an EDK2 relative path. It also includes a brief mention of a utility function from `edk2toollib.utility_functions`.

from edk2toollib.path_utilities import Edk2Path from pathlib import Path import tempfile # Create a dummy workspace and package for demonstration with tempfile.TemporaryDirectory() as tmpdir: workspace_path = Path(tmpdir) / "edk2_workspace" package_path = workspace_path / "MyPkg" (package_path / "MyModule").mkdir(parents=True) (package_path / "MyModule" / "MyModule.inf").touch() workspace_path.mkdir() package_path.mkdir() # Instantiate Edk2Path - note the performance warning in warnings section edk2_path_obj = Edk2Path(ws=workspace_path, package_path_list=[package_path]) # Example: Get an EDK2 relative path abs_module_path = package_path / "MyModule" / "MyModule.inf" edk2_relative_path = edk2_path_obj.GetEdk2RelativePathFromAbsolutePath(str(abs_module_path)) print(f"EDK2 Relative Path: {edk2_relative_path}") # Example using a utility function (requires a file to print) test_file = Path(tmpdir) / "test.txt" test_file.write_text("Hello, EDK2!") print("\nPrinting file data:") # PrintFileData is often used internally, no direct output capturing shown here for simplicity # The function itself prints to console, so we can't easily assert its output without mocking sys.stdout # For demonstration, we simply call it. # In a real scenario, you'd likely use a logger or capture stdout. # from edk2toollib.utility_functions import PrintFileData # PrintFileData(str(test_file)) print(f"Content of {test_file.name}: {test_file.read_text()}") # Simulate PrintFileData output
Debug
Known issues
gotchaIt is strongly recommended to use Python virtual environments when working with `edk2-pytool-library` (and related EDK2 tools). This helps prevent dependency conflicts with other Python projects and ensures a consistent development environment. This recommendation is consistently highlighted in the official documentation for both the library and related tools.
fix
Always activate a virtual environment before installing or using `edk2-pytool-library`: `python -m venv .venv && source .venv/bin/activate` (Linux/macOS) or `.venv\Scripts\activate.bat` (Windows).
affects: All versions
gotchaThe EDK2 build system (which `edk2-pytool-library` supports) is sensitive to spaces in certain environment variables. `WORKSPACE`, `PACKAGES_PATH`, and `EDK_TOOLS_BIN` must not contain space characters, even if the operating system permits them.
fix
Ensure that the directory paths assigned to `WORKSPACE`, `PACKAGES_PATH`, and `EDK_TOOLS_BIN` environment variables do not contain any spaces.
affects: All versions
breakingThe Project Mu Python packages for UEFI support and build tools have migrated to Tianocore and are now leveraged through `edk2-pytools`. This change implies that older build setups or documentation referencing Project Mu's tools may be outdated and require updates to align with the new `edk2-pytools` ecosystem.
fix
Review your build environment and scripts to ensure they are updated to use the `edk2-pytool-library` and `edk2-pytool-extensions` as part of the Tianocore `edk2-pytools` framework. Refer to the latest EDK2 build documentation for `stuart` (from `edk2-pytool-extensions`) for the current recommended patterns.
affects: Users migrating from Project Mu-based setups
gotchaThe `Edk2Path` class performs expensive package path and package validation during instantiation. If you are repeatedly using the same workspace root and packages path, it is strongly suggested to instantiate `Edk2Path` only once and pass that single instance to all consumers to avoid performance overhead.
fix
For scenarios involving frequent path operations within a consistent EDK2 workspace, create a single instance of `Edk2Path` and reuse it, rather than creating new instances multiple times.
affects: All versions
breakingAn issue was reported (June 2023) where Capsule Update fails from the OS due to changes in `inf_generator`, specifically an integrity file's location not being updated alongside other changes, leading to a 'file not found' error.
fix
Verify if a fix for this specific `inf_generator` issue has been released. If encountering this, consult the `edk2-pytool-library` GitHub issues or Tianocore documentation for potential workarounds or updates to the `inf_generator` usage that correctly handles integrity file paths.
affects: Potentially versions prior to a fix (if implemented after June 2023). Users on current versions should test this functionality.
Upgrade
Version history
0.23.13latest on PyPI · released Apr 7, 2026
Audit
Dependencies
pythonrequiredRequired runtime environment.
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
2
Amazon
1
Resources
edk2-pytool-library — pip install edk2-pytool-library · libregistry