Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frequenz-floss/setuptools-betterproto
A modern setuptools plugin to generate Python files from proto files using betterproto
https://github.com/frequenz-floss/setuptools-betterproto
betterproto code-generation frequenz grpc grpclib library plugin proto protobuf protocol-buffers python setuptools
Last synced: about 1 month ago
JSON representation
A modern setuptools plugin to generate Python files from proto files using betterproto
- Host: GitHub
- URL: https://github.com/frequenz-floss/setuptools-betterproto
- Owner: frequenz-floss
- License: mit
- Created: 2024-04-12T13:52:25.000Z (9 months ago)
- Default Branch: v0.x.x
- Last Pushed: 2024-05-23T08:56:56.000Z (7 months ago)
- Last Synced: 2024-05-23T09:04:38.697Z (7 months ago)
- Topics: betterproto, code-generation, frequenz, grpc, grpclib, library, plugin, proto, protobuf, protocol-buffers, python, setuptools
- Language: Python
- Homepage: https://frequenz-floss.github.io/setuptools-betterproto/
- Size: 1.06 MB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Archived
> [!WARNING]
> This repository has been archived due to doubts casted about [betterproto](https://github.com/danielgtaylor/python-betterproto) being a sustaintable project.# Betterproto Setuptools plugin
[![Build Status](https://github.com/frequenz-floss/setuptools-betterproto/actions/workflows/ci.yaml/badge.svg)](https://github.com/frequenz-floss/setuptools-betterproto/actions/workflows/ci.yaml)
[![PyPI Package](https://img.shields.io/pypi/v/setuptools-betterproto)](https://pypi.org/project/setuptools-betterproto/)
[![Docs](https://img.shields.io/badge/docs-latest-informational)](https://frequenz-floss.github.io/setuptools-betterproto/)## Introduction
A modern [`setuptools`](https://setuptools.pypa.io/) plugin to generate Python
files from proto files using [betterproto].This plugin is based on
[`repo-config`](https://frequenz-floss.github.io/frequenz-repo-config-python/)'s
[`grpc_tools`
plugin](https://frequenz-floss.github.io/frequenz-repo-config-python/v0.9/reference/frequenz/repo/config/setuptools/grpc_tools/).## Supported Platforms
The following platforms are officially supported (tested):
- **Python:** 3.11
- **Operating System:** Ubuntu Linux 20.04
- **Architectures:** amd64, arm64## Quick Start
To add automatic [betterproto] code generation to your project, you need to add
this package to your build-dependencies in the `pyproject.toml` file, for
example:```toml
[build-system]
requires = [
"setuptools == 68.1.0",
"setuptools-betterproto == 0.1.0",
]
build-backend = "setuptools.build_meta"
```This uses a default configuration as follows:
* `proto_path`: This is the root directory where the proto files are located.
By default, it is set to `.`.
* `proto_glob`: This is the glob pattern to match the proto files. The search
is done recursively. By default, it is set to `*.proto`.
* `include_paths`: This is a list of paths to be added to the protobuf
compiler's include path. By default, it is set to `[]`, but the `proto_path`
directory is always automatically added.
* `out_path`: This is the directory where the generated Python files will be
placed. By default, it is set to `.`.These defaults can be changed via the `pypackage.toml` file too. For example:
```toml
[tool.setuptools_betterproto]
proto_path = "proto"
include_paths = ["api-common-protos"]
out_path = "src"
```You should add [betterproto] as a dependency too, for example:
```toml
dependencies = ["betterproto == 2.0.0b6"]
```Once this is done, the conversion of the proto files to Python files should be
automatic. Just try building the package with:```sh
python -m pip install build
python -m build
```A new command to generate the files will be also added to `setuptools`, you can
run it manually with:
```sh
python -c 'import setuptools; setuptools.setup()' compile_betterproto
```You can also pass the configuration options via command line for quick testing,
try passing `--help` at the end of the command to see the available options.## Contributing
If you want to know how to build this project and contribute to it, please
check out the [Contributing Guide](CONTRIBUTING.md).## Similar projects
* [`setuptools-proto`](https://github.com/jameslan/setuptools-proto/): We didn't use this project because it seems a bit inactive and not widely used. It also seems to need some configuration as code, which we wanted to avoid.
[betterproto]: https://github.com/danielgtaylor/python-betterproto