Skip to content

Commit 28e38ad

Browse files
Migrate to protobuf-py and rename repo to connect-py (#274)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com> Signed-off-by: Stefan VanBuren <stefan@vanburen.xyz> Co-authored-by: Stefan VanBuren <stefan@vanburen.xyz>
1 parent a903d5f commit 28e38ad

108 files changed

Lines changed: 6041 additions & 3818 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CONTRIBUTING.md

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ jobs:
6464
with:
6565
python-version: ${{ matrix.python }}
6666

67+
# For conformance runner
6768
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
6869
with:
69-
go-version-file: protoc-gen-connect-python/go.mod
70-
cache-dependency-path: "**/go.mod"
70+
go-version: "^1.26"
7171

7272
- run: uv sync --frozen
7373

@@ -89,10 +89,6 @@ jobs:
8989
- name: run OTel tests
9090
run: uv run poe test-otel ${{ matrix.coverage == 'cov' && '--cov=connectrpc_otel --cov-report=xml' || '' }}
9191

92-
- name: run Go tests
93-
run: go test ./...
94-
working-directory: protoc-gen-connect-python
95-
9692
- name: run conformance tests
9793
# TODO: Debug stdin/stdout issues on Windows
9894
if: ${{ !startsWith(matrix.os, 'windows-') }}
@@ -122,28 +118,11 @@ jobs:
122118
working-directory: connectrpc-otel
123119

124120
- name: build codegen archives
125-
uses: goreleaser/goreleaser-action@5daf1e915a5f0af01ddbcd89a43b8061ff4f1a89 # v7.2.2
126-
with:
127-
version: "~> v2"
128-
args: release --snapshot --clean
129-
workdir: protoc-gen-connect-python
130-
131-
- run: |
132-
# Make sure uv doesn't build the project since the data files aren't ready yet.
133-
uv sync --frozen --no-install-project
134-
uv run --no-sync python scripts/generate_wheels.py
135-
working-directory: protoc-gen-connect-python
121+
run: uv build
122+
working-directory: protoc-gen-connectrpc
136123

137124
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
138125
if: github.event_name != 'pull_request'
139126
with:
140127
repository-url: https://test.pypi.org/legacy/
141128
skip-existing: true
142-
143-
- name: publish protoc-gen-connect-python
144-
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
145-
if: github.event_name != 'pull_request'
146-
with:
147-
repository-url: https://test.pypi.org/legacy/
148-
packages-dir: protoc-gen-connect-python/dist
149-
skip-existing: true

.github/workflows/release.yaml

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,15 @@ jobs:
1919

2020
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
2121

22-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
23-
with:
24-
go-version-file: protoc-gen-connect-python/go.mod
25-
cache-dependency-path: "**/go.mod"
26-
2722
- run: uv sync --frozen
2823

2924
- run: uv build
3025

3126
- name: build codegen archives
32-
uses: goreleaser/goreleaser-action@5daf1e915a5f0af01ddbcd89a43b8061ff4f1a89 # v7.2.2
33-
with:
34-
version: "~> v2"
35-
args: release --clean
36-
workdir: protoc-gen-connect-python
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
40-
- run: |
41-
# Make sure uv doesn't build the project since the data files aren't ready
42-
uv sync --frozen --no-install-project
43-
uv run --no-sync python scripts/generate_wheels.py
44-
working-directory: protoc-gen-connect-python
45-
46-
- uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
47-
with:
48-
subject-checksums: out/checksums.txt
49-
50-
- name: publish connect-python
51-
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
52-
with:
53-
skip-existing: true
27+
run: uv build
28+
working-directory: protoc-gen-connectrpc
5429

55-
- name: publish protoc-gen-connect-python
30+
- name: publish
5631
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
5732
with:
58-
packages-dir: protoc-gen-connect-python/dist
5933
skip-existing: true

.gitignore

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,7 @@ venv.bak/
110110
*.so
111111
*.dylib
112112

113-
# Test binary, build with `go test -c`
114-
*.test
115-
116-
# Output of the go coverage tool, specifically when used with LiteIDE
117-
*.out
118-
119113
.vscode
120114

121-
# generated Go binary
122-
protoc-gen-connect-python/protoc-gen-connect-python
123-
124-
# goreleaser archives
125-
out/
126-
127-
go.work.sum
128-
129115
# GitHub Actions temporary files
130116
.github/.tmp/

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Contributing to connect-python
1+
# Contributing to Connect
22

33
## Before You Contribute
44

@@ -30,8 +30,8 @@ $ git commit -s -m "your commit message"
3030
1. Fork and clone the repository:
3131

3232
```console
33-
$ gh repo fork connectrpc/connect-python --clone
34-
$ cd connect-python
33+
$ gh repo fork connectrpc/connect-py --clone
34+
$ cd connect-py
3535
```
3636

3737
2. Verify everything is working:

DEVELOPMENT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
1. Clone the repository:
1313

1414
```bash
15-
git clone https://github.com/connectrpc/connect-python
16-
cd connect-python
15+
git clone https://github.com/connectrpc/connect-py
16+
cd connect-py
1717
```
1818

1919
2. Install dependencies:

README.md

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# connect-python
1+
# Connect for Python
22

33
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4-
[![CI](https://github.com/connectrpc/connect-python/actions/workflows/ci.yaml/badge.svg)](https://github.com/connectrpc/connect-python/actions/workflows/ci.yaml)
5-
[![codecov](https://codecov.io/github/connectrpc/connect-python/graph/badge.svg)](https://codecov.io/github/connectrpc/connect-python)
6-
[![PyPI version](https://img.shields.io/pypi/v/connect-python)](https://pypi.org/project/connect-python)
7-
[![API Docs](https://img.shields.io/badge/API_Docs-connectrpc.github.io-blue)](https://connectrpc.github.io/connect-python/api/)
4+
[![CI](https://github.com/connectrpc/connect-py/actions/workflows/ci.yaml/badge.svg)](https://github.com/connectrpc/connect-py/actions/workflows/ci.yaml)
5+
[![codecov](https://codecov.io/github/connectrpc/connect-py/graph/badge.svg)](https://codecov.io/github/connectrpc/connect-py)
6+
[![PyPI version](https://img.shields.io/pypi/v/connect-py)](https://pypi.org/project/connect-py)
7+
[![API Docs](https://img.shields.io/badge/API_Docs-connectrpc.github.io-blue)](https://connectrpc.github.io/connect-py/api/)
88

99
A Python implementation of [Connect](https://connectrpc.com/): Protobuf RPC that works.
1010

@@ -51,12 +51,10 @@ A reasonable `buf.gen.yaml`:
5151
```yaml
5252
version: v2
5353
plugins:
54-
- remote: buf.build/protocolbuffers/python
55-
out: .
56-
- remote: buf.build/protocolbuffers/pyi
57-
out: .
54+
- remote: buf.build/bufbuild/py
55+
out: gen
5856
- remote: buf.build/connectrpc/python
59-
out: .
57+
out: gen
6058
```
6159
6260
Or, you can install the compiler (e.g. `pip install protoc-gen-connectrpc`), and
@@ -68,17 +66,35 @@ Then, you can use `protoc-gen-connectrpc` as a local plugin:
6866
out: .
6967
```
7068

71-
Alternatively, download a precompiled binary from the
72-
[releases](https://github.com/connectrpc/connect-python/releases).
73-
7469
`protoc-gen-connectrpc` is only needed for code generation. Your actual
7570
application should include `connectrpc` as a dependency for the runtime
7671
component.
7772

73+
#### google.protobuf compatibility
74+
75+
Connect defaults to targeting [protobuf-py](https://protobufpy.com) as the Protocol Buffers
76+
implementation but Google's Protocol Buffers for Python are also fully supported. Pass `protobuf=google`
77+
to the codegen plugin to use it.
78+
79+
```yaml
80+
version: v2
81+
plugins:
82+
- remote: buf.build/protocolbuffers/python
83+
out: .
84+
- remote: buf.build/protocolbuffers/pyi
85+
out: .
86+
- remote: buf.build/connectrpc/python
87+
out: .
88+
opt: protobuf=google
89+
```
90+
91+
If configuring a client for JSON codec, make sure to pass `connectrpc.compat.google_protobuf_json_codec`
92+
instead of `connectrpc.codec.proto_json_codec`.
93+
7894
### Basic Client Usage
7995

8096
```python
81-
from your_service_pb2 import HelloRequest, HelloResponse
97+
from your_service_pb import HelloRequest, HelloResponse
8298
from your_service_connect import HelloServiceClient
8399
84100
# Create async client
@@ -93,7 +109,7 @@ async def main():
93109

94110
```python
95111
from connectrpc.request import RequestContext
96-
from your_service_pb2 import HelloRequest, HelloResponse
112+
from your_service_pb import HelloRequest, HelloResponse
97113
from your_service_connect import HelloService, HelloServiceASGIApplication
98114
99115
class MyHelloService(HelloService):
@@ -110,7 +126,7 @@ app = HelloServiceASGIApplication(MyHelloService())
110126
### Basic Client Usage (Synchronous)
111127

112128
```python
113-
from your_service_pb2 import HelloRequest
129+
from your_service_pb import HelloRequest
114130
from your_service_connect import HelloServiceClientSync
115131
116132
# Create sync client
@@ -128,7 +144,7 @@ Check out [the docs](https://connectrpc.com/docs/python/getting-started) for mor
128144

129145
## Streaming Support
130146

131-
connect-python supports all RPC streaming types:
147+
Connect supports all RPC streaming types:
132148

133149
- **Unary**: Single request, single response
134150
- **Server Streaming**: Single request, multiple responses
@@ -236,25 +252,25 @@ We verify the following servers with ConnectRPC's conformance suite.
236252

237253
For ASGI servers:
238254

239-
- [pyvoy](https://pyvoy.dev) - Fully-featured ASGI server, enables all of Connect-Python's features
255+
- [pyvoy](https://pyvoy.dev) - Fully-featured ASGI server, enables all of Connect's features
240256
- [Uvicorn](https://www.uvicorn.org/) - Lightning-fast ASGI server for HTTP/1
241257

242258
For WSGI servers:
243259

244-
- [pyvoy](https://pyvoy.dev) - Fully-featured WSGI server, enables all of Connect-Python's features
260+
- [pyvoy](https://pyvoy.dev) - Fully-featured WSGI server, enables all of Connect's features
245261
- [Gunicorn](https://gunicorn.org/) - Python WSGI HTTP Server for HTTP/1
246262

247263
Other ASGI and WSGI servers should also generally work though we have found some issues with flakiness
248264
with our conformance tests. If you don't have any preference, we recommend one of the above servers.
249265

250266
## WSGI Support
251267

252-
connect-python provides full WSGI support via `ConnectWSGIApplication` for synchronous Python applications. This enables integration with traditional WSGI servers like Gunicorn and uWSGI.
268+
Connect provides full WSGI support via `ConnectWSGIApplication` for synchronous Python applications. This enables integration with traditional WSGI servers like Gunicorn and uWSGI.
253269

254270
```python
255271
from connectrpc.request import RequestContext
256272
from connectrpc.server import ConnectWSGIApplication
257-
from your_service_pb2 import Request, Response
273+
from your_service_pb import Request, Response
258274
from your_service_connect import YourService, YourServiceWSGIApplication
259275
260276
class YourServiceImpl(YourService):
@@ -275,7 +291,7 @@ app = YourServiceWSGIApplication(YourServiceImpl())
275291

276292
## Compression Support
277293

278-
connect-python supports multiple compression algorithms:
294+
Connect supports multiple compression algorithms:
279295

280296
- **gzip**: Built-in support, always available
281297
- **brotli**: Available when `brotli` package is installed
@@ -327,7 +343,7 @@ client = HelloServiceClient(
327343

328344
### Connect GET Support
329345

330-
connect-python automatically enables GET request support for methods marked with `idempotency_level = NO_SIDE_EFFECTS` in your proto files:
346+
Connect automatically enables GET request support for methods marked with `idempotency_level = NO_SIDE_EFFECTS` in your proto files:
331347

332348
```proto
333349
service YourService {
@@ -347,7 +363,7 @@ response = await client.get_data(request)
347363

348364
### CORS Support
349365

350-
connect-python works with any ASGI CORS middleware. For example, using Starlette:
366+
Connect works with any ASGI CORS middleware. For example, using Starlette:
351367

352368
```python
353369
from starlette.middleware.cors import CORSMiddleware

RELEASE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Releasing connect-python
1+
# Releasing Connect
22

3-
This document outlines how to create a release of connect-python.
3+
This document outlines how to create a release of Connect.
44

55
1. Clone the repo, ensuring you have the latest main.
66

@@ -11,7 +11,7 @@ This document outlines how to create a release of connect-python.
1111

1212
Note the new version X.Y.Z in the updated files.
1313

14-
3. Open a PR titled "Prepare for vX.Y.Z" ([Example PR: #60](https://github.com/connectrpc/connect-python/pull/60)) and assign the `connectrpc/python` group as reviewers. Once it's approved by at
14+
3. Open a PR titled "Prepare for vX.Y.Z" ([Example PR: #60](https://github.com/connectrpc/connect-py/pull/60)) and assign the `connectrpc/python` group as reviewers. Once it's approved by at
1515
least one other maintainer and CI passes, merge it.
1616

1717
_Make sure no new commits are merged until the release is complete._

buf.gen.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
version: v2
22
plugins:
3-
# NOTE: v26.0 is the earliest version supporting protobuf==5.
4-
- remote: buf.build/protocolbuffers/python:v26.0
3+
- local: protoc-gen-py
54
out: src/connectrpc/_gen
6-
- remote: buf.build/protocolbuffers/pyi:v26.0
5+
- local: protoc-gen-connectrpc
76
out: src/connectrpc/_gen

0 commit comments

Comments
 (0)