skillfed

xmacro

a simple XML macro tool

xmacro v1.2.1 77.5K downloads/30d#14,517 on PyPI15
Permissive license MIT Abandoned released

What it is and what it does

xmacro is a simplified XML macro language inspired by ROS's xacro, designed to preprocess URDF and SDF robot description files. It runs independently of ROS and can be installed via pip. The tool supports value macros (named constants substituted into XML), block macros (parameterized XML fragments), math expressions within substitution braces, file inclusion, and conditional blocks. It provides both a command-line interface and a Python API for integration into build or launch workflows.

The package includes two specialized variants: xmacro4sdf and xmacro4urdf, which add pre-defined geometry and inertia macros specific to each format, along with path resolution for model:// and package:// URIs. Macro nesting is supported up to 5 levels deep. The implementation uses Python's eval() for expression evaluation, which the documentation notes is unsafe for untrusted input.

Use it for:

  • Reduce duplication in URDF robot descriptions by defining reusable inertia and geometry macros for common shapes
  • Generate multiple SDF model variants from a single template by overriding macro values at parse time
  • Preprocess robot description files in ROS 2 launch scripts using the Python API before deployment
  • Conditionally include or exclude robot components based on macro parameters without manual file editing
  • Include common macro definitions across multiple URDF or SDF files via the xmacro_include tag

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

xmacro is a command-line and Python tool for defining and expanding XML macros—named values, parameterized blocks, and conditional includes—to generate expanded XML files suitable for URDF and SDF robot description formats.

Yes, if you need XML macro expansion for URDF or SDF files and are comfortable with an abandoned package. The tool is simple, has no dependencies, and works well for its stated purpose. However, do not use it for untrusted or adversarial input due to eval()-based expression evaluation, and be aware that no security patches or feature updates will be released.

Install

xmacro on PyPI

pip

pip install xmacro

uv

uv add xmacro

poetry

poetry add xmacro

Installing xmacro

Before you install

Installation is straightforward via pip with no runtime dependencies. However, the package is abandoned—last release was in January 2022 and the repository received its final commit in September 2022, so no active maintenance or security updates should be expected.

License in practice

MIT license is permissive and places no restrictions on use, modification, or distribution in proprietary or open-source projects.

Quickstart

# Command-line usage
pip install xmacro
xmacro input.xml.xmacro > output.xml

# Python API usage
from xmacro.xmacro import XMLMacro
xmacro = XMLMacro()
xmacro.set_xml_file('input.xml.xmacro')
xmacro.generate()
xmacro.to_file('output.xml')

Verify before relying

  • Whether the package works reliably with modern Python versions given its abandonment status
  • Whether math expression evaluation via eval() poses security risks in untrusted input scenarios

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 1,669 days since the last release
Last repo commit
First released
Downloads 77,532/month — #14,517 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: xmacro-1.2.1-py3-none-any.whl

Keywords: xml, macro, xacro, xmacro, sdformat, sdf, urdf

Tags

xml macro expansionurdf macro preprocessorsdf template generationxml templating toolrobot description macroxacro alternativexml value substitution
robot-descriptionxml-templatingabandoned

More Markup packages