Skip to main content

Parsing, formatting and rendering toolkit for Gerber X3 file format

Project description

PyGerber

GitHub release GitHub Release Date - Published_At PyPI release PyPI Downloads Supported Python versions Supported Python implementations license_mit coverage GitHub tag checks state Pull requests Open issues GitHub repo size GitHub code size in bytes GitHub Repo stars Poetry Code Style

📖 Overview

PyGerber is a collection of tools aimed at simplifying the use of the Gerber X3 format. It is based on Ucamco's The Gerber Layer Format Specification. Revision 2024.05 (Available on Ucamco's webpage.

PyGerber can be used both as a executable with use of its command line interface and as a Python library.

PyGerber supports modern solutions available in the latest version of the standard (2024.05). At the same time, it includes the implementation of most outdated and selected removed functionalities. This allows it to be used not only with files compliant with the X3 standard but also with those compliant with X2, RS-274X, and RS-274D. Due to limited access to files in older standards and ambiguities within them, there is a risk that some older functionalities may behave incorrectly.

If you have found a bug in the PyGerber library, please report it in the Issues section of our project's repository. We will be glad to examine your report and possibly fix the problem.

If you have any questions or suggestions, please open a new discussion thread in the Discussions section of our repository. We will be happy to help you and discuss your ideas.

📦 Installation

PyGerber can be installed with pip from PyPI:

pip install pygerber

This way only the core of PyGerber features will be installed. It will not include language server, SVG rendering support and other optional features. If you want to install all available features, include all extras set in installation request, like this:

pip install pygerber[all]

Alternatively, it is also possible to install it directly from repository:

pip install git+https://github.com/Argmaster/pygerber

📚 Documentation

PyGerber has a online documentation hosted on Github Pages. It will be a great starting point for your journey with PyGerber. You can find documentation here here. If you are looking for documentation of older version of PyGerber, please use version selector dropdown available next to the title in top bar menu.

📜 License

PyGerber is licensed under MIT license. You can find full text of the license in the LICENSE file in the root directory of the repository.

🛠 Tools

Collection of tool available in PyGerber constantly grows. Most of the tools can be accessed both with command line and as a Python API. Below you can find list of all currently available ones:

  • Image generator (PNG/JPEG)
  • Code formatter
  • Language server (requires language_server extras) (Visual Studio Code extension available)
  • Pygments Gerber syntax lexer plugin (requires pygments extras)

🖮 PyGerber APIs

PyGerber provides APIs for accessing most of its functionalities. There are selected modules designed to be used as libraries, they reexport public parts of implementation in a convenient way. Avoid importing stuff from modules not listed below and not mentioned in documentation, as this may inflict suffering and damnation upon you 💀 (Just joking, but they may get deleted/moved at any time, so you know 😼).

Below you can find list of available APIs:

  • pygerber.gerber.api
  • pygerber.gerber.ast
  • pygerber.gerber.ast.nodes
  • pygerber.gerber.compiler
  • pygerber.gerber.parser
  • pygerber.gerber.formatter
  • pygerber.builder.gerber
  • pygerber.builder.rvmc
  • pygerber.vm
  • pygerber.vm.commands
  • pygerber.vm.pillow
  • pygerber.vm.types

If you need something that is not reexported from those modules, eg. some exception class you need to catch, please open an Issue so we can evaluate that issue and possibly add missing reexport.

💻 PyGerber CLI

PyGerber provides non-interactive command line interface which provides means to access some of its features. pygerber command is available after installation and can be used to access tools with use of subcommands.

To check version of PyGerber available in your environment, you can use:

pygerber --version

To access PyGerbers image rendering feature, you can use render subcommand. Assuming that your Gerber file is named source.gbr and you want to render a PNG image of it, you can use following command:

pygerber render raster source.gbr -o output.png

This will create output.png file in current working directory. Depending on your image size you may need to adjust --dpmm parameter to raise or lower the resolution of image.

example_pcb_image

PyGerber has also a lot more options related to rendering available. For extensible guide on how to use PyGerber CLI, please refer to documentation.

§ Language Server

PyGerber provides Gerber X3/X2 Language Server conforming to Language Servere Protocol defined by Microsoft. It can be enabled by installing PyGerber extras set language-server with following command:

pip install pygerber[language-server]

Afterwards you can use following command to check if PyGerber correctly recognized that language server feature should be enabled:

pygerber is-language-server-available

If you have encountered a problem with language server please report it in the Issues section of Github repository of this project.

If you have a suggestion for improvement, please open a new discussion thread in the Discussions section of our repository.

To fully utilize power of this language server you can use Visual Studio Code extension Gerber X3/X2 Format Support (argmaster.gerber-x3-x2-format-support). Repository of this extension is available here. If you encounter any problems with that extension, please report them in the Issues section of its repository. If you are not sure whether the problem is caused by extension or by language server, please report it in the Issues section of the extension, we will move it to PyGerber repository if necessary.

Development

For development guidelines please visit documentation Development section here.

Acknowledgments

I would like to thank Professor Janusz Młodzianowski from the University of Gdańsk, who inspired me with the idea to implement the Gerber format at the beginning of my bachelor's degree. I would like to also express my gratitude to Karel Tavernier, the long-time steward of the Gerber format, for his support and expert guidance during my work on this project. Without them, this project would have never come to life. Finally, I would like to thank all the people who have contributed, are contributing and will contribute to PyGerber. Your help is invaluable and I am grateful for it.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygerber-3.0.0a2.tar.gz (130.0 kB view details)

Uploaded Source

Built Distribution

pygerber-3.0.0a2-py3-none-any.whl (196.8 kB view details)

Uploaded Python 3

File details

Details for the file pygerber-3.0.0a2.tar.gz.

File metadata

  • Download URL: pygerber-3.0.0a2.tar.gz
  • Upload date:
  • Size: 130.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pygerber-3.0.0a2.tar.gz
Algorithm Hash digest
SHA256 49ca9700dd338486a3efcb6ab57213fe43c5aac8b69f5241aa025c3c9785c3b3
MD5 3908330a5a6871d119a87de02daa41ac
BLAKE2b-256 5c5cf9298c30b5d5a1639eafef0ec50c0d1e86c8bfa2c26187e9b913f931819b

See more details on using hashes here.

Provenance

File details

Details for the file pygerber-3.0.0a2-py3-none-any.whl.

File metadata

  • Download URL: pygerber-3.0.0a2-py3-none-any.whl
  • Upload date:
  • Size: 196.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pygerber-3.0.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 0211d8a611627d423315ed2314724784d1d7425b1cca381fef50c71735789066
MD5 48eae71496497278606fc5451811b35d
BLAKE2b-256 69463b7e15356f6eed6025e1d92546da4f5f4b1f2e4e3aba1e04f5eae976a613

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page