2 Commits

Author SHA1 Message Date
Bouke Versteegh
bde6d06835 Merge pull request #99 from boukeversteegh/release-v2.0.0b1
Release v2.0.0b1
2020-07-05 10:20:37 +02:00
boukeversteegh
eaa4f7f5d9 Release v2.0.0b1 2020-07-04 14:00:35 +02:00
7 changed files with 67 additions and 39 deletions

View File

@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Versions suffixed with `b*` are in `beta` and can be installed with `pip install --pre betterproto`.
## [2.0.0b1] - 2020-07-04
[Upgrade Guide](./docs/upgrading.md)
> Several bugfixes and improvements required or will require small breaking changes, necessitating a new version.
> `2.0.0` will be released once the interface is stable.
- Add support for gRPC and **stream-stream** [#83](https://github.com/danielgtaylor/python-betterproto/pull/83)
- Switch from to `poetry` for development [#75](https://github.com/danielgtaylor/python-betterproto/pull/75)
- Fix No arguments are generated for stub methods when using import with proto definition
- Fix two packages with the same name suffix should not cause naming conflict [#25](https://github.com/danielgtaylor/python-betterproto/issues/25)
- Fix Import child package from root [#57](https://github.com/danielgtaylor/python-betterproto/issues/57)
- Fix Import child package from package [#58](https://github.com/danielgtaylor/python-betterproto/issues/58)
- Fix Import parent package from child package [#59](https://github.com/danielgtaylor/python-betterproto/issues/59)
- Fix Import root package from child package [#60](https://github.com/danielgtaylor/python-betterproto/issues/60)
- Fix Import root package from root [#61](https://github.com/danielgtaylor/python-betterproto/issues/61)
- Fix ALL_CAPS message fields are parsed incorrectly. [#11](https://github.com/danielgtaylor/python-betterproto/issues/11)
## [1.2.5] - 2020-04-27
- Add .j2 suffix to python template names to avoid confusing certain build tools [#72](https://github.com/danielgtaylor/python-betterproto/pull/72)

View File

@@ -40,7 +40,7 @@ This project exists because I am unhappy with the state of the official Google p
This project is a reimplementation from the ground up focused on idiomatic modern Python to help fix some of the above. While it may not be a 1:1 drop-in replacement due to changed method names and call patterns, the wire format is identical.
## Installation & Getting Started
## Installation
First, install the package. Note that the `[compiler]` feature flag tells it to install extra dependencies only needed by the `protoc` plugin:
@@ -52,6 +52,12 @@ pip install "betterproto[compiler]"
pip install betterproto
```
*Betterproto* is under active development. To install the latest beta version, use `pip install --pre betterproto`.
## Getting Started
### Compiling proto files
Now, given you installed the compiler and have a proto file, e.g `example.proto`:
```protobuf
@@ -149,7 +155,7 @@ service Echo {
You can use it like so (enable async in the interactive shell first):
```py
```python
>>> import echo
>>> from grpclib.client import Channel
@@ -174,8 +180,8 @@ Both serializing and parsing are supported to/from JSON and Python dictionaries
For compatibility the default is to convert field names to `camelCase`. You can control this behavior by passing a casing value, e.g:
```py
>>> MyMessage().to_dict(casing=betterproto.Casing.SNAKE)
```python
MyMessage().to_dict(casing=betterproto.Casing.SNAKE)
```
### Determining if a message was sent
@@ -300,7 +306,22 @@ datetime.datetime(2019, 1, 1, 11, 59, 58, 800000, tzinfo=datetime.timezone.utc)
Join us on [Slack](https://join.slack.com/t/betterproto/shared_invite/zt-f0n0uolx-iN8gBNrkPxtKHTLpG3o1OQ)!
First, make sure you have Python 3.6+ and `poetry` installed, along with the official [Protobuf Compiler](https://github.com/protocolbuffers/protobuf/releases) for your platform. Then:
### Requirements
- Python (3.6 or higher)
- [protoc](https://grpc.io/docs/protoc-installation/) (3.12 or higher)
*Needed to compile `.proto` files and run the tests*
- [poetry](https://python-poetry.org/docs/#installation)
*Needed to install dependencies in a virtual environment*
- make ([ubuntu](https://www.howtoinstall.me/ubuntu/18-04/make/), [windows](https://stackoverflow.com/questions/32127524/how-to-install-and-use-make-in-windows), [mac](https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/))
*Needed to conveniently run development tasks.*
*Alternatively, manually run the commands defined in the [Makefile](./Makefile)*
### Setup
```sh
# Get set up with the virtual env & dependencies
@@ -310,7 +331,7 @@ poetry install
poetry shell
```
To benefit from the collection of standard development tasks ensure you have make installed and run `make help` to see available tasks.
Run `make help` to see all available development tasks.
### Code style

View File

@@ -6,8 +6,7 @@ xfail = {
"namespace_keywords", # 70
"namespace_builtin_types", # 53
"googletypes_struct", # 9
"googletypes_value", # 9
"enum_skipped_value", # 93
"googletypes_value", # 9,
"import_capitalized_package",
"example", # This is the example in the readme. Not a test.
}

View File

@@ -1,12 +0,0 @@
syntax = "proto3";
message Test {
enum MyEnum {
ZERO = 0;
ONE = 1;
// TWO = 2;
THREE = 3;
FOUR = 4;
}
MyEnum x = 1;
}

View File

@@ -1,18 +0,0 @@
from betterproto.tests.output_betterproto.enum_skipped_value import (
Test,
TestMyEnum,
)
import pytest
@pytest.mark.xfail(reason="#93")
def test_message_attributes():
assert (
Test(x=TestMyEnum.ONE).to_dict()["x"] == "ONE"
), "MyEnum.ONE is not serialized to 'ONE'"
assert (
Test(x=TestMyEnum.THREE).to_dict()["x"] == "THREE"
), "MyEnum.THREE is not serialized to 'THREE'"
assert (
Test(x=TestMyEnum.FOUR).to_dict()["x"] == "FOUR"
), "MyEnum.FOUR is not serialized to 'FOUR'"

16
docs/upgrading.md Normal file
View File

@@ -0,0 +1,16 @@
# Upgrade Guide
## [1.2.5] to [2.0.0b1]
### Updated package structures
Generated code now strictly follows the *package structure* of the `.proto` files.
Consequently `.proto` files without a package will be combined in a single `__init__.py` file.
To avoid overwriting existing `__init__.py` files, its best to compile into a dedicated subdirectory.
Upgrading:
- Remove your previously compiled `.py` files.
- Create a new *empty* directory, e.g. `generated` or `lib/generated/proto` etcetera.
- Regenerate your python files into this directory
- Update import statements, e.g. `import ExampleMessage from generated`

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "betterproto"
version = "1.2.5"
version = "2.0.0b1"
description = "A better Protobuf / gRPC generator & library"
authors = ["Daniel G. Taylor <danielgtaylor@gmail.com>"]
readme = "README.md"