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
9 changes: 2 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
- macos-15
- windows-2025
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
Expand All @@ -32,13 +31,9 @@ jobs:
- "3.15"
- "3.15t"
native-ext: [true, false]
exclude:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a couple of built wheels but not adding significant CI time anymore

# Currently many dependencies need wheel builds on 3.15 which is slow, so only run on push
- python-version: ${{ github.event_name == 'pull_request' && '3.15' }}
- python-version: ${{ github.event_name == 'pull_request' && '3.15t' }}
env:
# When bumping, also bump top-level env in release.yaml
MATURIN_ARGS: ${{ matrix.python-version == '3.11' && '--features pyo3/abi3-py311' || '' }}
MATURIN_ARGS: ${{ (matrix.python-version == '3.11' || matrix.python-version == '3.12') && '--features pyo3/abi3-py311' || '' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install uv with Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -96,7 +91,7 @@ jobs:
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
version: "0.12.23"
python-version: "3.10"
python-version: "3.11"
- run: uv sync --locked
- run: uv run poe lint
- run: uv run poe format
Expand Down
117 changes: 30 additions & 87 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,126 +16,71 @@ permissions:
env:
# When bumping, also bump MATURIN_ARGS in ci.yaml
# maturin flags to build targets we publish non-abi3 wheels for
UNSTABLE_API_FLAGS: -i 3.10 -i 3.12 -i 3.13 -i 3.14 -i 3.14t
UNSTABLE_API_FLAGS: -i 3.13 -i 3.14 -i 3.14t -i 3.15 -i 3.15t
# maturin flags to build targets we publish abi3 wheels for
ABI3_FLAGS: -i 3.11 --features pyo3/abi3-py311
ABI3T_FLAGS: -i 3.15t --features pyo3/abi3t-py315

jobs:
ext-linux:
runs-on: ${{ matrix.platform.runner }}
ext:
runs-on: ${{ matrix.runner }}
strategy:
matrix:
platform:
include:
- runner: ubuntu-24.04
target: x86_64
manylinux: auto
- runner: ubuntu-24.04
target: x86_64
manylinux: musllinux_1_2
- runner: ubuntu-24.04-arm
target: aarch64
manylinux: auto
- runner: ubuntu-24.04-arm
target: aarch64
manylinux:
- auto
- musllinux_1_2
manylinux: musllinux_1_2
- runner: windows-2025
target: x86_64
- runner: windows-11-arm
target: aarch64
- runner: macos-15
target: aarch64
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: 3.x

- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0

# We only publish abi3 wheels for Windows
- name: Build wheels
if: runner.os != 'Windows'
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
target: ${{ matrix.platform.target }}
target: ${{ matrix.target }}
args: --release --out ../../dist ${{ env.UNSTABLE_API_FLAGS }}
sccache: true
manylinux: ${{ matrix.manylinux }}
working-directory: packages/protobuf-py-ext

- name: Build abi3 wheels
- name: Build abi3 wheel
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
target: ${{ matrix.platform.target }}
target: ${{ matrix.target }}
args: --release --out ../../dist ${{ env.ABI3_FLAGS }}
sccache: true
manylinux: ${{ matrix.manylinux }}
working-directory: packages/protobuf-py-ext

- name: Upload wheels
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-linux-${{ matrix.platform.target }}-${{ matrix.manylinux }}
path: dist

# We only publish abi3 wheels for Windows
ext-windows:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: windows-2025
target: x86_64
- runner: windows-11-arm
target: aarch64
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0

- name: Build abi3 wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
args: --release --out ../../dist ${{ env.ABI3_FLAGS }} --features pyo3/generate-import-lib
sccache: true
working-directory: packages/protobuf-py-ext

- name: Upload wheels
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist

ext-macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-15
target: aarch64
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: |
3.10
3.11
3.12
3.13
3.14
3.14t

- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0

- name: Build wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
target: ${{ matrix.platform.target }}
args: --release --out ../../dist ${{ env.UNSTABLE_API_FLAGS }}
sccache: true
working-directory: packages/protobuf-py-ext

- name: Build abi3 wheels
- name: Build abi3t wheel
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
with:
target: ${{ matrix.platform.target }}
args: --release --out ../../dist ${{ env.ABI3_FLAGS }}
target: ${{ matrix.target }}
args: --release --out ../../dist ${{ env.ABI3T_FLAGS }}
sccache: true
manylinux: ${{ matrix.manylinux }}
working-directory: packages/protobuf-py-ext

- name: Upload wheels
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-macos-${{ matrix.platform.target }}
name: wheels-${{ matrix.runner }}-${{ matrix.target }}${{ matrix.manylinux && format('-{0}', matrix.manylinux) || '' }}
path: dist

ext-sdist:
Expand All @@ -160,9 +105,7 @@ jobs:
runs-on: ubuntu-26.04
environment: ${{ (github.event_name == 'workflow_dispatch' && 'pypi-test') || (github.event_name == 'push' && github.ref_type == 'tag' && 'pypi-release') || null }}
needs:
- ext-linux
- ext-windows
- ext-macos
- ext
- ext-sdist
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "protobuf-py"
version = "0.6.0"
description = "Idiomatic Protocol Buffers for Python."
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.11"
license = "Apache-2.0"
license-files = ["LICENSE"]
keywords = ["protobuf"]
Expand All @@ -13,11 +13,11 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Programming Language :: Python :: Free Threading",
"Topic :: File Formats",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down Expand Up @@ -394,7 +394,7 @@ skip-magic-trailing-comma = true
docstring-code-format = true

[tool.ruff.lint]
typing-extensions = false
typing-extensions = true
select = ["ALL"]
ignore = [
# Rules recommended to ignore when using ruff formatting
Expand Down
16 changes: 6 additions & 10 deletions src/protobuf/_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from __future__ import annotations

from copy import copy, deepcopy
from typing import TYPE_CHECKING, Any, ClassVar, Generic, overload
from typing import TYPE_CHECKING, Any, ClassVar, Generic, Self, overload

from typing_extensions import Buffer, TypeVar

Expand Down Expand Up @@ -49,8 +49,6 @@
from ._registry import Registry
from ._typing import JsonValue

Self = TypeVar("Self", bound="Message")

# TypeVar for making Message generic over its field names
FieldNamesT = TypeVar("FieldNamesT", bound=str, default=Any)

Expand Down Expand Up @@ -113,7 +111,7 @@ class Message(Generic[FieldNamesT], metaclass=MessageMeta): # noqa: PLW1641
_present: set[int]
_unknown_fields: dict[int, list[bytes]] | None

def __new__(cls: type[Self], *_args: Any, **_kwargs: Any) -> Self:
def __new__(cls, *_args: Any, **_kwargs: Any) -> Self:
msg = object.__new__(cls)
object_setattr(msg, "_present", set())
object_setattr(msg, "_unknown_fields", None)
Expand Down Expand Up @@ -579,7 +577,7 @@ def __eq__(self, other: object, /) -> bool:

@classmethod
def from_json(
cls: type[Self],
cls,
json: str | bytes | bytearray,
*,
ignore_unknown_fields: bool = False,
Expand Down Expand Up @@ -610,9 +608,7 @@ def from_json(
return msg

@classmethod
def from_binary(
cls: type[Self], data: Buffer, *, ignore_unknown_fields: bool = False
) -> Self:
def from_binary(cls, data: Buffer, *, ignore_unknown_fields: bool = False) -> Self:
"""Create a new message by parsing serialized binary data.

To merge into an existing message, use [`merge_from_binary`][].
Expand Down Expand Up @@ -725,7 +721,7 @@ def _merge_from(self: Self, source: Self, ignore_unknown_fields: bool) -> None:

@classmethod
def _from_json_value(
cls: type[Self],
cls,
data: JsonValue,
*,
ignore_unknown_fields: bool = False,
Expand Down Expand Up @@ -787,7 +783,7 @@ def _get_or_init_unknown_fields(self) -> dict[int, list[bytes]]:

@classmethod
def __get_pydantic_core_schema__(
cls: type[Self], _source_type: Any, handler: GetCoreSchemaHandler
cls, _source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
from ._jsonschema import build_pydantic_core_schema # noqa: PLC0415

Expand Down
3 changes: 1 addition & 2 deletions src/protobuf/wkt/_mixin/_any.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

from __future__ import annotations

from typing import TYPE_CHECKING, TypeVar, cast, overload
from typing import TYPE_CHECKING, Self, TypeVar, cast, overload

from protobuf import DescMessage, Message

T = TypeVar("T", bound=Message)
Self = TypeVar("Self", bound="AnyMixin")


class AnyMixin:
Expand Down
4 changes: 1 addition & 3 deletions src/protobuf/wkt/_mixin/_duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
from __future__ import annotations

from datetime import timedelta
from typing import TYPE_CHECKING, TypeVar
from typing import TYPE_CHECKING, Self

from ._const import MICROSECOND_DELTA, SECOND_AS_NANOS

Self = TypeVar("Self", bound="DurationMixin")


class DurationMixin:
__slots__ = ()
Expand Down
12 changes: 5 additions & 7 deletions src/protobuf/wkt/_mixin/_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from collections.abc import Mapping, Sequence
from typing import TYPE_CHECKING, Literal, TypeAlias, TypeVar, cast

from typing_extensions import Self

if TYPE_CHECKING:
from protobuf import Oneof
from protobuf.wkt import ListValue, NullValue, Struct, Value
Expand Down Expand Up @@ -49,9 +51,7 @@ def __init__(self, *, fields: dict[str, Value] | None = None) -> None:
fields: dict[str, Value]

@classmethod
def from_python(
cls: type[SelfStruct], data: Mapping[str, ValueTypeParam]
) -> SelfStruct:
def from_python(cls, data: Mapping[str, ValueTypeParam]) -> Self:
"""Create a Struct from a Python dict.

Examples:
Expand Down Expand Up @@ -111,7 +111,7 @@ def __init__(
)

@classmethod
def from_python(cls: type[SelfValue], value: ValueTypeParam) -> SelfValue:
def from_python(cls, value: ValueTypeParam) -> Self:
"""Create a Value from a Python value.

Args:
Expand Down Expand Up @@ -246,9 +246,7 @@ def __init__(self, *, values: list[Value] | None = None) -> None: ...
values: list[Value]

@classmethod
def from_python(
cls: type[SelfListValue], values: Sequence[ValueTypeParam]
) -> SelfListValue:
def from_python(cls, values: Sequence[ValueTypeParam]) -> Self:
"""Create a ListValue from a list of Python values.

Examples:
Expand Down
4 changes: 1 addition & 3 deletions src/protobuf/wkt/_mixin/_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from datetime import datetime, timedelta, timezone
from time import time_ns
from typing import TYPE_CHECKING, TypeVar
from typing import TYPE_CHECKING, Self

from ._const import (
EPOCH_DATETIME,
Expand All @@ -25,8 +25,6 @@
TIMESTAMP_NANOS_MIN,
)

Self = TypeVar("Self", bound="TimestampMixin")


class TimestampMixin:
__slots__ = ()
Expand Down
Loading
Loading