Skip to content
Merged
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
7 changes: 4 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
steps:
- uses: actions/checkout@v7
with:
Expand Down Expand Up @@ -200,10 +201,10 @@ jobs:
key: ${{ needs.blazingmq-dependency.outputs.deps_cache_key }}
- name: Restore cached BlazingMQ build artifacts
run: tar xzf blazingmq_artifacts.tar.gz
- name: Set up uv with Python 3.14
- name: Set up uv with Python 3.15
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: "3.14"
python-version: "3.15"
activate-environment: true
venv-path: venv
- name: Install Python dependencies
Expand Down Expand Up @@ -251,7 +252,7 @@ jobs:
- name: Set up uv with Python 3.14
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
python-version: "3.14"
python-version: "3.15"
activate-environment: true
venv-path: venv
- name: Install Python dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
matrix:
os: [ubuntu-latest]
cibw_python:
["cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
["cp39", "cp310", "cp311", "cp312", "cp313", "cp314", "cp315"]
cibw_arch: ${{ fromJSON(needs.choose_architectures.outputs.cibw_arches) }}

steps:
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
matrix:
os: [macos-14]
cibw_python:
["cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
["cp39", "cp310", "cp311", "cp312", "cp313", "cp314", "cp315"]
cibw_arch: ["arm64"]

steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[![MessageQueue](https://img.shields.io/badge/MessageQueue-blue)](#)
[![Documentation](https://img.shields.io/badge/Documentation-blue)](https://bloomberg.github.io/blazingmq)
[![Code Style](https://img.shields.io/badge/Black-black)](#)
![Supported Python versions](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue?logo=python)
![Supported Python versions](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14%20%7C%203.15-blue?logo=python)

# BlazingMQ Python SDK

Expand Down
2 changes: 1 addition & 1 deletion docs/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CI to test on all other combinations in your pull request. See
`.github/workflows/build.yaml` for more details on how we build and
test on all supported interpreters and architectures.

The instructions below assume `PYEXEC=python3.14` and will focus on
The instructions below assume `PYEXEC=python3.15` and will focus on
Linux only. This should be sufficient in most cases.

Before following any of the instructions, make sure to `git clone` the project onto the host machine.
Expand Down
1 change: 1 addition & 0 deletions news/98.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support Python 3.15
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build-backend = "setuptools.build_meta"
name = "blazingmq"
description = "Python BlazingMQ API"
readme = "README.md"
requires-python = ">=3.9,<3.15"
requires-python = ">=3.9,<3.16"
authors = [
{name = "Bloomberg Finance LP"}
]
Expand All @@ -29,6 +29,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
Expand All @@ -52,7 +53,7 @@ filename = "CHANGELOG.md"
directory = "news"

[tool.cibuildwheel]
build = ["cp39-*", "cp310-*", "cp311-*", "cp312-*", "cp313-*", "cp314-*"]
build = ["cp39-*", "cp310-*", "cp311-*", "cp312-*", "cp313-*", "cp314-*", "cp315-*"]
skip = "*-musllinux_*"
manylinux-x86_64-image = "manylinux_2_28"

Expand Down
6 changes: 5 additions & 1 deletion src/blazingmq/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ def _construct_user_agent_prefix(user_agent_prefix: bytes) -> bytes:
"""Construct the user agent prefix for use by the Cython layer."""
python_version = platform.python_version().encode("ascii", errors="strict")
blazingmq_version = __version__.encode("ascii", errors="strict")
sdk_identifier = b"blazingmq(python" + python_version + b"):" + blazingmq_version
sdk_identifier = b"blazingmq(py" + python_version + b"):" + blazingmq_version
# libbmq requires the user agent to be shorter than 128 bytes. The prefix
# is at most 96 bytes, plus one byte for the separating space, which leaves
# 30 bytes for the SDK identifier.
sdk_identifier = sdk_identifier[:30]
if user_agent_prefix:
return user_agent_prefix + b" " + sdk_identifier
return sdk_identifier
Expand Down
54 changes: 49 additions & 5 deletions tests/unit/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def dummy2():
# THEN
_, kwargs = ext_cls.call_args
assert re.fullmatch(
rb"mylib:1\.0 blazingmq\(python[^)]+\):\S+",
rb"mylib:1\.0 blazingmq\(py[^)]+\):\S+",
kwargs["user_agent_prefix"],
)

Expand Down Expand Up @@ -964,7 +964,7 @@ def dummy():
# THEN
_, kwargs = ext_cls.call_args
assert re.fullmatch(
rb"mylib:1\.0 blazingmq\(python[^)]+\):\S+",
rb"mylib:1\.0 blazingmq\(py[^)]+\):\S+",
kwargs["user_agent_prefix"],
)

Expand All @@ -987,7 +987,7 @@ def dummy():
# THEN
_, kwargs = ext_cls.call_args
assert re.fullmatch(
rb"blazingmq\(python[^)]+\):\S+",
rb"blazingmq\(py[^)]+\):\S+",
kwargs["user_agent_prefix"],
)

Expand All @@ -1011,7 +1011,7 @@ def dummy():
# THEN
_, kwargs = ext_cls.call_args
assert re.fullmatch(
rb"blazingmq\(python[^)]+\):\S+",
rb"blazingmq\(py[^)]+\):\S+",
kwargs["user_agent_prefix"],
)

Expand All @@ -1037,6 +1037,50 @@ def dummy():
assert len(kwargs["user_agent_prefix"]) < 128


@mock.patch("blazingmq._session.platform.python_version", return_value="3.15.0rc2")
@mock.patch("blazingmq._session.__version__", "1.2.3.dev456")
@mock.patch("blazingmq._session.ExtSession")
def test_session_user_agent_prefix_with_long_versions_satisfies_bmq_length(
ext_cls, _python_version
):
# GIVEN
ext_cls.mock_add_spec([])
user_agent_prefix = b"x" * 96

def dummy():
pass

# WHEN
Session(
dummy,
on_message=dummy,
broker="some_uri",
user_agent_prefix=user_agent_prefix,
)

# THEN
_, kwargs = ext_cls.call_args
assert len(kwargs["user_agent_prefix"]) < 128
assert kwargs["user_agent_prefix"].startswith(user_agent_prefix + b" ")


@mock.patch("blazingmq._session.platform.python_version", return_value="3.15.0rc2")
@mock.patch("blazingmq._session.__version__", "1.2.3.dev456")
def test_user_agent_sdk_identifier_does_not_depend_on_prefix(_python_version):
# GIVEN
from blazingmq._session import _construct_user_agent_prefix

# WHEN
without_prefix = _construct_user_agent_prefix(b"")
with_short_prefix = _construct_user_agent_prefix(b"mylib:1.0")
with_long_prefix = _construct_user_agent_prefix(b"x" * 96)

# THEN
assert with_short_prefix == b"mylib:1.0 " + without_prefix
assert with_long_prefix == b"x" * 96 + b" " + without_prefix
assert len(with_long_prefix) < 128


@mock.patch("blazingmq._session.ExtSession")
def test_session_user_agent_prefix_satisfies_bmq_printable_precondition(ext_cls):
# GIVEN
Expand Down Expand Up @@ -1165,7 +1209,7 @@ def dummy():
# THEN
_, kwargs = ext_cls.call_args
assert re.fullmatch(
rb"my lib:1\.0 blazingmq\(python[^)]+\):\S+",
rb"my lib:1\.0 blazingmq\(py[^)]+\):\S+",
kwargs["user_agent_prefix"],
)

Expand Down
16 changes: 8 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py314,lint, lint-cython, lint-types, black, docs
envlist = py315,lint, lint-cython, lint-types, black, docs
minversion = 3.2.1
isolated_build = true

Expand Down Expand Up @@ -32,45 +32,45 @@ description =

[testenv:.package]
description = Isolated build environment
basepython = python3.14
basepython = python3.15

[testenv:py314-cov]
[testenv:py315-cov]
usedevelop = True
commands = {[testenv]commands_cov}
deps = -rrequirements-test-coverage.txt

[testenv:lint]
description = Run lint checker on Python files
basepython = python3.14
basepython = python3.15
deps = flake8
skip_install = true
commands = {basepython} -m flake8 --config={toxinidir}/.flake8 src

[testenv:lint-cython]
description = Run lint checker on Cython files
basepython = python3.14
basepython = python3.15
deps = flake8
skip_install = true
commands = {basepython} -m flake8 --config={toxinidir}/.flake8.cython src


[testenv:lint-types]
description = Run mypy checker on examples
basepython = python3.14
basepython = python3.15
deps =
mypy
commands = {basepython} -m mypy --strict examples

[testenv:black]
description = Check that python files are formatted with black
basepython = python3.14
basepython = python3.15
deps = black
skip_install = true
commands = {basepython} -m black --check --verbose src tests

[testenv:docs]
description = Generate library documentation
basepython = python3.14
basepython = python3.15
deps = -rrequirements-lint-docs.txt
commands = make -C docs html
{basepython} -c 'print("documentation available under file://{toxworkdir}/docs_out/index.html")'
Loading