Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions .github/CONTRIBUTING.md

This file was deleted.

29 changes: 4 additions & 25 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ jobs:
with:
python-version: ${{ matrix.python }}

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

- run: uv sync --frozen

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

- name: run Go tests
run: go test ./...
working-directory: protoc-gen-connect-python

- name: run conformance tests
# TODO: Debug stdin/stdout issues on Windows
if: ${{ !startsWith(matrix.os, 'windows-') }}
Expand Down Expand Up @@ -122,28 +118,11 @@ jobs:
working-directory: connectrpc-otel

- name: build codegen archives
uses: goreleaser/goreleaser-action@5daf1e915a5f0af01ddbcd89a43b8061ff4f1a89 # v7.2.2
with:
version: "~> v2"
args: release --snapshot --clean
workdir: protoc-gen-connect-python

- run: |
# Make sure uv doesn't build the project since the data files aren't ready yet.
uv sync --frozen --no-install-project
uv run --no-sync python scripts/generate_wheels.py
working-directory: protoc-gen-connect-python
run: uv build
working-directory: protoc-gen-connectrpc

- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
if: github.event_name != 'pull_request'
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true

- name: publish protoc-gen-connect-python
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
if: github.event_name != 'pull_request'
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: protoc-gen-connect-python/dist
skip-existing: true
32 changes: 3 additions & 29 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,15 @@ jobs:

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

- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: protoc-gen-connect-python/go.mod
cache-dependency-path: "**/go.mod"

- run: uv sync --frozen

- run: uv build

- name: build codegen archives
uses: goreleaser/goreleaser-action@5daf1e915a5f0af01ddbcd89a43b8061ff4f1a89 # v7.2.2
with:
version: "~> v2"
args: release --clean
workdir: protoc-gen-connect-python
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: |
# Make sure uv doesn't build the project since the data files aren't ready
uv sync --frozen --no-install-project
uv run --no-sync python scripts/generate_wheels.py
working-directory: protoc-gen-connect-python

- uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
with:
subject-checksums: out/checksums.txt

- name: publish connect-python
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
with:
skip-existing: true
run: uv build
working-directory: protoc-gen-connectrpc

- name: publish protoc-gen-connect-python
- name: publish
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
with:
packages-dir: protoc-gen-connect-python/dist
skip-existing: true
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,7 @@ venv.bak/

.vscode

# generated Go binary
protoc-gen-connect-python/protoc-gen-connect-python

# goreleaser archives
out/

go.work.sum

# GitHub Actions temporary files
.github/.tmp/
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to connect-python
# Contributing to Connect

## Before You Contribute

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

```console
$ gh repo fork connectrpc/connect-python --clone
$ cd connect-python
$ gh repo fork connectrpc/connect-py --clone
$ cd connect-py
```

2. Verify everything is working:
Expand Down
4 changes: 2 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
1. Clone the repository:

```bash
git clone https://github.com/connectrpc/connect-python
cd connect-python
git clone https://github.com/connectrpc/connect-py
cd connect-py
```

2. Install dependencies:
Expand Down
64 changes: 40 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# connect-python
# Connect for Python

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

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

Expand Down Expand Up @@ -51,12 +51,10 @@ A reasonable `buf.gen.yaml`:
```yaml
version: v2
plugins:
- remote: buf.build/protocolbuffers/python
out: .
- remote: buf.build/protocolbuffers/pyi
out: .
- remote: buf.build/bufbuild/py
out: gen
- remote: buf.build/connectrpc/python
out: .
out: gen
```

Or, you can install the compiler (e.g. `pip install protoc-gen-connectrpc`), and
Expand All @@ -68,17 +66,35 @@ Then, you can use `protoc-gen-connectrpc` as a local plugin:
out: .
```

Alternatively, download a precompiled binary from the
[releases](https://github.com/connectrpc/connect-python/releases).

`protoc-gen-connectrpc` is only needed for code generation. Your actual
application should include `connectrpc` as a dependency for the runtime
component.

#### google.protobuf compatibility

Connect defaults to targeting [protobuf-py](https://protobufpy.com) as the Protocol Buffers
implementation but Google's Protocol Buffers for Python are also fully supported. Pass `protobuf=google`
to the codegen plugin to use it.

```yaml
version: v2
plugins:
- remote: buf.build/protocolbuffers/python
out: .
- remote: buf.build/protocolbuffers/pyi
out: .
- remote: buf.build/connectrpc/python
out: .
opt: protobuf=google
```

If configuring a client for JSON codec, make sure to pass `connectrpc.compat.google_protobuf_json_codec`
instead of `connectrpc.codec.proto_json_codec`.

### Basic Client Usage

```python
from your_service_pb2 import HelloRequest, HelloResponse
from your_service_pb import HelloRequest, HelloResponse
from your_service_connect import HelloServiceClient

# Create async client
Expand All @@ -93,7 +109,7 @@ async def main():

```python
from connectrpc.request import RequestContext
from your_service_pb2 import HelloRequest, HelloResponse
from your_service_pb import HelloRequest, HelloResponse
from your_service_connect import HelloService, HelloServiceASGIApplication

class MyHelloService(HelloService):
Expand All @@ -110,7 +126,7 @@ app = HelloServiceASGIApplication(MyHelloService())
### Basic Client Usage (Synchronous)

```python
from your_service_pb2 import HelloRequest
from your_service_pb import HelloRequest
from your_service_connect import HelloServiceClientSync

# Create sync client
Expand All @@ -128,7 +144,7 @@ Check out [the docs](https://connectrpc.com/docs/python/getting-started) for mor

## Streaming Support

connect-python supports all RPC streaming types:
Connect supports all RPC streaming types:

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

For ASGI servers:

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

For WSGI servers:

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

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

## WSGI Support

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

```python
from connectrpc.request import RequestContext
from connectrpc.server import ConnectWSGIApplication
from your_service_pb2 import Request, Response
from your_service_pb import Request, Response
from your_service_connect import YourService, YourServiceWSGIApplication

class YourServiceImpl(YourService):
Expand All @@ -275,7 +291,7 @@ app = YourServiceWSGIApplication(YourServiceImpl())

## Compression Support

connect-python supports multiple compression algorithms:
Connect supports multiple compression algorithms:

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

### Connect GET Support

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

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

### CORS Support

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

```python
from starlette.middleware.cors import CORSMiddleware
Expand Down
6 changes: 3 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Releasing connect-python
# Releasing Connect

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

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

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

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

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
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
least one other maintainer and CI passes, merge it.

_Make sure no new commits are merged until the release is complete._
Expand Down
5 changes: 2 additions & 3 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: v2
plugins:
# NOTE: v26.0 is the earliest version supporting protobuf==5.
- remote: buf.build/protocolbuffers/python:v26.0
- local: protoc-gen-py
out: src/connectrpc/_gen
- remote: buf.build/protocolbuffers/pyi:v26.0
- local: protoc-gen-connectrpc
out: src/connectrpc/_gen
Loading
Loading