Metadata-Version: 2.1
Name: pygerber
Version: 3.0.0a0
Summary: Parsing, formatting and rendering toolkit for Gerber X3 file format
Home-page: https://github.com/Argmaster/pygerber
License: MIT
Keywords: gerber,pcb,embedded,images,x3
Author: Krzysztof Wisniewski
Author-email: argmaster.world@gmail.com
Requires-Python: >=3.8,<3.13
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Manufacturing
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: OS Independent
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: File Formats
Classifier: Topic :: Multimedia
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Multimedia :: Graphics :: Presentation
Classifier: Topic :: Multimedia :: Graphics :: Viewers
Classifier: Topic :: Printing
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Topic :: Software Development :: Embedded Systems
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Provides-Extra: all
Provides-Extra: language-server
Provides-Extra: svg
Requires-Dist: click (>=8.1.3,<9.0.0)
Requires-Dist: drawsvg (>=2.3.0,<3.0.0) ; extra == "svg" or extra == "all"
Requires-Dist: lsprotocol (>=2023.0.0a3,<2024.0.0) ; extra == "language-server" or extra == "all"
Requires-Dist: numpy (>=1.24.4,<2.0.0) ; python_version >= "3.8" and python_version <= "3.11"
Requires-Dist: numpy (>=1.26.1,<2.0.0) ; python_version >= "3.12" and python_version < "3.13"
Requires-Dist: pillow (>=10.0.0,<11.0.0)
Requires-Dist: pydantic (>=2.3,<3.0)
Requires-Dist: pygls (>=1.0.2,<2.0.0) ; extra == "language-server" or extra == "all"
Requires-Dist: pyparsing (>=3.1.0,<4.0.0)
Requires-Dist: typing-extensions (>=4.12.2,<5.0.0)
Requires-Dist: tzlocal (>=5.0.1,<6.0.0)
Project-URL: Documentation, https://argmaster.github.io/pygerber/latest
Project-URL: Repository, https://github.com/Argmaster/pygerber
Description-Content-Type: text/markdown

<p align="center">
   <img width="400" src="https://github.com/Argmaster/pygerber/assets/56170852/b7aeb3e1-cd59-4f5b-b078-c01272461367" alt="" />
</p>

# PyGerber

<p align="center">
  <a href="https://github.com/Argmaster/pygerber/releases/"><img src="https://img.shields.io/github/v/release/Argmaster/pygerber?style=flat" alt="GitHub release"></a>
  <a href="https://github.com/Argmaster/pygerber/releases"><img src="https://img.shields.io/github/release-date/Argmaster/pygerber" alt="GitHub Release Date - Published_At"></a>
  <a href="https://pypi.org/project/pygerber"><img src="https://img.shields.io/pypi/v/pygerber?style=flat" alt="PyPI release"></a>
  <a href="https://pypi.org/project/pygerber/"><img src="https://img.shields.io/pypi/dm/pygerber.svg?label=PyPI%20downloads" alt="PyPI Downloads"></a>
  <a href="https://pypi.org/project/pygerber"><img src="https://img.shields.io/pypi/pyversions/pygerber?style=flat" alt="Supported Python versions"></a>
  <a href="https://pypi.org/project/pygerber"><img src="https://img.shields.io/pypi/implementation/pygerber?style=flat" alt="Supported Python implementations"></a>
  <a href="https://github.com/argmaster/pygerber/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Argmaster/pygerber" alt="license_mit"></a>
  <a href="https://codecov.io/gh/Argmaster/pygerber"><img src="https://codecov.io/gh/Argmaster/pygerber/branch/main/graph/badge.svg?token=VM09IHO13U" alt="coverage"></a>
  <a href="https://img.shields.io/github/checks-status/Argmaster/pygerber/main"><img src="https://img.shields.io/github/checks-status/Argmaster/pygerber/main" alt="GitHub tag checks state"></a>
  <a href="https://github.com/Argmaster/pygerber/pulls"><img src="https://img.shields.io/github/issues-pr/Argmaster/pygerber?style=flat" alt="Pull requests"></a>
  <a href="https://github.com/Argmaster/pygerber/issues"><img src="https://img.shields.io/github/issues-raw/Argmaster/pygerber?style=flat" alt="Open issues"></a>
  <a href="https://github.com/Argmaster/pygerber"><img src="https://img.shields.io/github/repo-size/Argmaster/pygerber" alt="GitHub repo size"></a>
  <a href="https://github.com/Argmaster/pygerber"><img src="https://img.shields.io/github/languages/code-size/Argmaster/pygerber" alt="GitHub code size in bytes"></a>
  <a href="https://github.com/Argmaster/pygerber"><img src="https://img.shields.io/github/stars/Argmaster/pygerber" alt="GitHub Repo stars"></a>
  <a href="https://python-poetry.org/"><img src="https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json" alt="Poetry"></a>
  <a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code Style"></a>
</p>

## 📖 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](https://www.ucamco.com/files/downloads/file_en/456/gerber-layer-format-specification-revision-2024-05_en.pdf).

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](https://github.com/Argmaster/pygerber/issues/new/choose) 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](https://github.com/Argmaster/pygerber/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](https://argmaster.github.io/pygerber/latest). 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](https://github.com/Argmaster/pygerber/blob/main/LICENSE.md) 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
  ([Visual Studio Code extension available](https://marketplace.visualstudio.com/items?itemName=argmaster.gerber-x3-x2-format-support))

## 🖮 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.gerberx3.api`
- `pygerber.gerberx3.ast`
- `pygerber.gerberx3.ast.nodes`
- `pygerber.gerberx3.compiler`
- `pygerber.gerberx3.parser`
- `pygerber.gerberx3.formatter`
- `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](https://github.com/Argmaster/pygerber/issues/new/choose) 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:

```bash
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:

```bash
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](https://github.com/Argmaster/pygerber/assets/56170852/9bca28bf-8aa6-4215-aac1-62c386490485)

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](https://microsoft.github.io/language-server-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](https://github.com/Argmaster/pygerber/issues/new/choose) section of Github
repository of this project.

If you have a suggestion for improvement, please open a new discussion thread in the
[Discussions](https://github.com/Agrmaster/pygerber/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](https://marketplace.visualstudio.com/items?itemName=argmaster.gerber-x3-x2-format-support)
(`argmaster.gerber-x3-x2-format-support`). Repository of this extension is available
[here](https://github.com/Argmaster/vscode-gerber-format-support). If you encounter any
problems with that extension, please report them in the
[Issues](https://github.com/Argmaster/vscode-gerber-format-support/issues/new) 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](https://github.com/Argmaster/vscode-gerber-format-support/issues/new) section
of the extension, we will move it to PyGerber repository if necessary.

## Development

For development guidelines please visit documentation `Development` section
[here](https://argmaster.github.io/pygerber/latest).

## 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.

