PyAVD Utilities (Internal)
PyAVD-Utils is a Python library providing Rust-based utilities primarily used by the `pyavd` library for Arista Network Automation. It is explicitly not intended for direct user consumption and therefore does not follow standard semantic versioning. Releases are ad-hoc and tied to the development of `pyavd`.
Common errors
-
ERROR: Could not build wheels for pyavd-utils, which is required to install pyproject.toml-based projects
cause The Rust toolchain (rustup, cargo) is not installed or not in your system's PATH, preventing the Rust source code from compiling into a Python wheel.fixInstall Rust and Cargo first. On Linux/macOS, use: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` and then `source "$HOME/.cargo/env"`. -
AttributeError: module 'pyavd_utils' has no attribute 'some_function'
cause You are attempting to call a function that either does not exist in the current `pyavd-utils` version, has been renamed, or was removed. The API is unstable and changes frequently.fixConsult the `pyavd-utils` source code (or the `pyavd` project that consumes it) for the exact function names and signatures for your installed version, or upgrade `pyavd` which may require a specific compatible `pyavd-utils` version. -
TypeError: argument 'data': 'str' object cannot be converted to 'bytes'
cause A Rust-bound function expects a byte string (e.g., `bytes`) but received a Python string (`str`). This is a common FFI (Foreign Function Interface) type mismatch.fixEncode the Python string to bytes before passing it to the function, for example: `my_string.encode('utf-8')`.
Warnings
- breaking This library is NOT intended for direct user consumption. It does not follow semantic versioning, and its API is highly unstable, subject to breaking changes without notice or deprecation cycles. It is compiled against specific `pyavd` versions.
- gotcha Installation requires a Rust toolchain (rustup, cargo) to be present on your system. If Rust is not installed, `pip install` will fail with compilation errors.
- gotcha Functions exposed from Rust often expect byte strings for input (e.g., `bytes` or `&[u8]`) and may return byte strings or Rust-specific types, requiring careful handling for Python compatibility.
Install
-
pip install pyavd-utils -
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source "$HOME/.cargo/env" pip install pyavd-utils
Imports
- str_to_md5
from pyavd_utils import str_to_md5
Quickstart
from pyavd_utils import str_to_md5
# WARNING: This library is NOT intended for direct user consumption.
# Its API is unstable and may change without notice, and it does not
# follow semantic versioning. Use at your own risk.
data_string = "Hello, pyavd-utils!"
# Rust-bound functions often expect bytes, not str
md5_hash = str_to_md5(data_string.encode('utf-8'))
print(f"MD5 of '{data_string}': {md5_hash}")