xacro
xacro is a macro language for XML
What it is and what it does
Xacro is a macro preprocessor for XML that allows you to define reusable templates and macros, then expand them into full XML documents. It reduces repetition and improves readability by letting you write shorter, more maintainable XML source files that are transformed into the final XML output. The package depends only on pyyaml and requires Python 3.8 or later.
It is commonly used in robotics and configuration contexts where XML files would otherwise contain significant duplication. You write xacro source files with macro definitions and calls, then process them through xacro to generate the expanded XML output.
Use it for:
- Generate robot configuration files in ROS by defining reusable component macros instead of repeating XML blocks
- Preprocess XML configuration files to reduce boilerplate and improve maintainability across multiple similar configs
- Template XML documents where sections repeat with minor parameter variations
- Build XML files programmatically using macro definitions rather than string concatenation
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Xacro is an XML macro language that lets you write shorter, more readable XML files by defining macros that expand into larger XML expressions.
Yes, if you work with XML files that contain repetition or need templating. The package is actively maintained, has low install friction, and no known vulnerabilities. The unclear license treatment is a minor concern—review the BSD 3-Clause text in the repository to confirm it aligns with your project before committing to it.
Install
xacro on PyPI
pip
pip install xacrouv
uv add xacropoetry
poetry add xacroInstalling xacro
Before you install
Low install friction with a single runtime dependency (pyyaml). The package is actively maintained with a recent commit on 2026-04-07 and has been in active development since its first release on 2018-09-18.
License in practice
License treatment is unclear; the package uses a BSD 3-Clause-style license text but no SPDX identifier is recorded. You should review the full license text in the repository before use to confirm it meets your project's requirements.
Quickstart
pip install xacro
import xacro
xacro.process_file('input.xacro', output='output.xml')
Requires Python 3.8 or later; input file must be a valid xacro XML document with macro definitions or includes.
Verify before relying
- Whether the BSD 3-Clause license text is the canonical license or if an SPDX identifier should be assigned
- Whether xacro is primarily used within the ROS ecosystem or has broader XML-processing applications
Package facts
| License | Copyright Robert Haschke, Bielefeld University Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.… (full text in the JSON record) (unclear) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pyyaml |
| Maintenance | actively maintained — 351 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 201,771/month — #9,664 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: xacro-2.1.1-py3-none-any.whl
Tags
More Markup packages
PyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
markdown-it-pyA Python markdown parser that converts markdown…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
et-xmlfileet_xmlfile writes large XML files with minimal…
permissive · top 1,000 on PyPI
tomlkitParses and edits TOML files while preserving…
permissive · top 1,000 on PyPI
docstring-parserParses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
xmacroxmacro is a command-line and Python tool for…
permissive · top 15,000 on PyPI
zope.talzope.tal implements the Template Attribute…
unclear · top 15,000 on PyPI
defusedxmlDefusedxml hardens Python's standard XML…
permissive · top 1,000 on PyPI
mkdocs-macros-pluginExtends MkDocs with Jinja2 templating to use…
permissive · top 5,000 on PyPI
xmldiffxmldiff compares two XML files or trees and…
permissive · top 15,000 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
pcodedmpDisassembles VBA p-code from Microsoft Office…
copyleft · top 5,000 on PyPI
zope.pagetemplatezope.pagetemplate provides a templating system…
unclear · top 15,000 on PyPI
uri-templateExpands RFC 6570 URI Templates with variable…
permissive · top 1,000 on PyPI
clvm-toolsCompiles a LISP-like smart-contract language…
permissive · top 15,000 on PyPI