CMSIS-Pack Manager
cmsis-pack-manager is a Python module, Rust crate, and command-line utility designed for managing CMSIS-Pack indexes and caches. It enables users to query for embedded device information such as processor types, flash algorithms, and memory layouts within Python programs or via its `pack-manager` CLI. The library leverages a fast Rust backend for performance. The current stable Python version is 0.6.0, with ongoing development and updates released periodically.
Warnings
- gotcha Building `cmsis-pack-manager` from source on non-x86 architectures (e.g., ARM-based systems like Raspberry Pi) or with newer Python versions (e.g., Python 3.11) can encounter build failures. This is often due to underlying Rust build requirements or specific `maturin`/`cffi` interactions.
- breaking Python 3.6 support has been removed in recent development versions. While PyPI metadata currently indicates `>=3.6`, newer internal releases and the Rust backend's evolution have dropped support for older Python versions.
- deprecated The `milksnake` runtime dependency was replaced by `maturin` for building the Python bindings to the Rust backend. While this is an internal build change, users compiling from source or relying on specific older build environments might be affected.
- gotcha The cache directory where CMSIS-Packs are stored, once set, is generally not easily changeable without manually re-downloading packs. While this warning primarily applies to GUI-based pack managers like the Eclipse plugin, the underlying principle of managing a persistent local pack repository applies. Programmatic changes to the cache location might require manual intervention or re-initialization to reflect.
Install
-
pip install cmsis-pack-manager
Imports
- Cache
from cmsis_pack_manager import Cache
- CmsisPackManager
from cmsis_pack_manager.cmsis_pack_manager import CmsisPackManager
Quickstart
from cmsis_pack_manager import Cache
from cmsis_pack_manager.cmsis_pack_manager import CmsisPackManager
# Initialize the cache and manager
cache = Cache(False, False) # Args: no_create, no_setup_logging
cmsis_manager = CmsisPackManager(cache)
print(f"CMSIS-Pack cache directory: {cache.data_path()}")
# Update the pack index (requires network access and can take time)
# This line is commented out for quickstart to avoid network call by default
# cmsis_manager.update_pdsc_idx()
# List some installed packs (will be empty if no packs updated/installed)
packs = cmsis_manager.get_installed_packs()
if packs:
print("Installed Packs:")
for pack in packs:
print(f" - {pack.vendor}::{pack.pack_id}@{pack.version}")
else:
print("No CMSIS-Packs found in cache. Run `pack-manager update` or `cmsis_manager.update_pdsc_idx()` to fetch them.")
# Example: Find a device (requires packs to be installed)
# device = cmsis_manager.get_device_by_name("ATSAMD21E15A")
# if device:
# print(f"Found device: {device.name}, Vendor: {device.vendor}")
# else:
# print("Device not found. Ensure relevant packs are installed.")