Pygerber
Python implementation of Gerber X3/X2 standard with 2D rendering engine.
Install / Use
/learn @Argmaster/PygerberREADME
📖 Overview
PyGerber is a collection of tools that simplify working with the Gerber X3 format in
Python. It is based on Ucamco's
The Gerber Layer Format Specification, Revision 2024.05 (available on
Ucamco's website).
PyGerber can be used both as an executable (via a command-line interface) and as a Python library.
PyGerber supports modern features from the latest version of the standard (2024.05). At the same time, it implements many older and removed functionalities for backwards compatibility. This makes it usable with files compliant with X3 as well as with X2, RS-274X, and RS-274D. Because access to files in older standards is limited and those standards contain ambiguities, some legacy behaviors may be incorrect.
If you find a bug in the PyGerber library, please file a bug report using one of the issue templates available on the Create new issue page in the PyGerber repository. We will examine reports and fix issues when possible.
If you have questions or suggestions, please open a discussion in the Discussions section of the repository.
📦 Installation
Install PyGerber from PyPI with pip:
pip install pygerber
This installs the core features only. The language server, SVG rendering support, and other optional features are available via extras. To install all extras use:
pip install pygerber[all]
To install the latest development version, use the GitHub repository URL with the git+
prefix:
pip install git+https://github.com/Argmaster/pygerber
📚 Documentation
PyGerber has online documentation hosted on GitHub Pages. It's a great starting point for using PyGerber: PyGerber documentation. For documentation of older versions, use the version selector next to the title in the top bar.
📜 License
PyGerber is licensed under the MIT License. The full text is available in the LICENSE file at the root of the repository.
Some testing assets and example files are distributed under different licenses; their
license files are provided alongside the assets. For example, some files from KiCad demo
projects are licensed under CC BY-SA 4.0.
🛠 Tools
The collection of tools available in PyGerber constantly grows. Some tools are exposed via the API, others include a command-line interface. Below is a list of currently available tools:
- Image renderer (PNG/JPEG/SVG)
[API][CLI] - Code formatter
[API][CLI] - Gerber code generation
[API] - Language server (requires
language_serverextras) (Visual Studio Code extension available)[CLI] - Pygments Gerber syntax lexer plugin (requires
pygmentsextras)[CLI]
🖮 PyGerber APIs
PyGerber provides APIs for accessing most of its functionality. The modules listed below are intended for use as stable library APIs; they re-export public parts of the implementation in a convenient way. Avoid importing from modules not listed here or not documented, as those modules are not part of public APIs and may be changed or removed at any time.
Below you can find a list of available APIs:
pygerber.gerber.api(open issue)pygerber.gerber.ast(open issue)pygerber.gerber.ast.nodes(open issue)pygerber.gerber.compiler(open issue)pygerber.gerber.parser(open issue)pygerber.gerber.formatter(open issue)pygerber.builder.gerber(open issue)pygerber.builder.rvmc(open issue)pygerber.vm(open issue)pygerber.vm.commands(open issue)pygerber.vm.types(open issue)pygerber.vm.pillow(open issue)pygerber.vm.shapely(open issue)
If you need a symbol that is not re-exported from these modules (for example, an exception class you need to catch), please open an issue using the corres
