From 155feddc7f594479c73b0ba7cc2cc6df4c00f511 Mon Sep 17 00:00:00 2001 From: YuxuanLiuTier4Desktop <619684051@qq.com> Date: Tue, 2 Jun 2026 22:35:51 +0900 Subject: [PATCH 1/4] fix(ci): pin protobuf codegen deps to uv.lock via build constraints Co-authored-by: Cursor --- .github/workflows/build.yaml | 3 ++- .github/workflows/docs.yaml | 3 ++- README.md | 6 ++++- scripts/cloudflare_pages_build.sh | 3 ++- scripts/export_build_constraints.sh | 39 +++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 4 deletions(-) create mode 100755 scripts/export_build_constraints.sh diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 792fb3f..c8c4019 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -57,7 +57,8 @@ jobs: - name: Build Package if: success() run: | - uv build + scripts/export_build_constraints.sh /tmp/build-constraints.txt + uv build -b /tmp/build-constraints.txt - name: Export requirements.txt run: | diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index e9bdaec..96d6e03 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -39,6 +39,7 @@ jobs: run: | . /opt/ros/humble/setup.sh && \ uv sync --all-extras --dev --all-packages && \ - uv build --all-packages + scripts/export_build_constraints.sh /tmp/build-constraints.txt && \ + uv build --all-packages -b /tmp/build-constraints.txt - run: | . /opt/ros/humble/setup.sh && uv run mkdocs gh-deploy --strict --force \ No newline at end of file diff --git a/README.md b/README.md index db365fb..b9dfed5 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,13 @@ This method builds Python packages (wheel files) that can be installed using `uv git clone --recursive https://github.com/tier4/sync_tooling.git cd sync_tooling -uv build --all-packages +scripts/export_build_constraints.sh /tmp/build-constraints.txt +uv build --all-packages -b /tmp/build-constraints.txt ``` +`export_build_constraints.sh` writes pinned protobuf codegen dependency versions from +`uv.lock` so isolated `uv build` does not re-resolve newer Hatch hook dependencies. + This will generate a `dist` directory with the built packages, and the `dist/*.whl` files can be installed using `pip`: diff --git a/scripts/cloudflare_pages_build.sh b/scripts/cloudflare_pages_build.sh index 9b69127..48c27f2 100755 --- a/scripts/cloudflare_pages_build.sh +++ b/scripts/cloudflare_pages_build.sh @@ -23,5 +23,6 @@ dpkg --fsys-tarfile libgvc6*.deb | tar -xf - -C graphviz/ graphviz_dir="$(realpath graphviz)" export PATH="$PATH:$graphviz_dir/usr/bin" uv sync --all-packages --all-extras -uv build --all-packages +scripts/export_build_constraints.sh /tmp/build-constraints.txt +uv build --all-packages -b /tmp/build-constraints.txt uv run mkdocs build --strict \ No newline at end of file diff --git a/scripts/export_build_constraints.sh b/scripts/export_build_constraints.sh new file mode 100755 index 0000000..4828c3c --- /dev/null +++ b/scripts/export_build_constraints.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Copyright 2025 TIER IV, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -euo pipefail + +if [[ $# -lt 1 ]]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +out="$1" +pattern='^(protobuf|mypy-protobuf|hatch-protobuf|types-protobuf)==' + +strip_constraints() { + grep -E "$pattern" | sed -E 's/\s*\\?\s*$//' | awk '{print $1}' +} + +tmp="$(mktemp)" +trap 'rm -f "$tmp"' EXIT + +uv export --frozen --package sync-tooling-msgs --only-group dev 2>/dev/null | strip_constraints >"$tmp" + +if ! grep -q '^types-protobuf==' "$tmp"; then + uv export --frozen --package sync-tooling-msgs 2>/dev/null | strip_constraints >>"$tmp" +fi + +sort -u "$tmp" >"$out" From 5a251f7f1bb1defc5fa2b732737a629055675ad8 Mon Sep 17 00:00:00 2001 From: YuxuanLiuTier4Desktop <619684051@qq.com> Date: Tue, 2 Jun 2026 22:45:37 +0900 Subject: [PATCH 2/4] fix(ci): constrain uv sync builds to uv.lock protobuf codegen deps uv sync builds sync-tooling-msgs in an isolated environment before pytest, which could generate *_pb2.py with a newer protoc than the locked runtime (6.33.5 gencode vs 6.33.4 runtime). Apply build-constraint-dependencies so editable installs use the same pins as uv build -b. Co-authored-by: Cursor --- pyproject.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c89e66b..996ed16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,13 @@ diag-worker = "diag_worker.main:main" [tool.uv] python-preference = "only-system" +# Pin codegen deps during `uv sync` workspace builds (see scripts/export_build_constraints.sh). +build-constraint-dependencies = [ + "protobuf==6.33.4", + "mypy-protobuf==5.0.0", + "hatch-protobuf==0.5.0", + "types-protobuf==6.32.1.20251210", +] [tool.uv.sources] journal_monitor = { workspace = true } From fe8ce1fff8e879731510dce2bf3cf99914950f74 Mon Sep 17 00:00:00 2001 From: YuxuanLiuTier4Desktop <619684051@qq.com> Date: Tue, 2 Jun 2026 22:48:37 +0900 Subject: [PATCH 3/4] chore: record build-constraint-dependencies in uv.lock uv lock revision 3 captures workspace build constraints so uv sync installs sync-tooling-msgs with the same protobuf pins as uv build -b. Co-authored-by: Cursor --- uv.lock | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/uv.lock b/uv.lock index aa647d3..acbf5cf 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 2 +revision = 3 requires-python = ">=3.10" resolution-markers = [ "python_full_version >= '3.14' and sys_platform == 'win32'", @@ -26,6 +26,12 @@ members = [ "sync-tooling", "sync-tooling-msgs", ] +build-constraints = [ + { name = "hatch-protobuf", specifier = "==0.5.0" }, + { name = "mypy-protobuf", specifier = "==5.0.0" }, + { name = "protobuf", specifier = "==6.33.4" }, + { name = "types-protobuf", specifier = "==6.32.1.20251210" }, +] [[package]] name = "aiostream" From 51b096c86eb9ddc6aafbb67b373dde84848818ed Mon Sep 17 00:00:00 2001 From: YuxuanLiuTier4Desktop <619684051@qq.com> Date: Tue, 2 Jun 2026 23:03:19 +0900 Subject: [PATCH 4/4] docs: explain uv sync codegen constraints and lock bump procedure Document why build-constraint-dependencies must stay aligned with uv.lock when bumping protobuf, and note the same pins in export_build_constraints.sh. Co-authored-by: Cursor --- README.md | 6 ++++++ scripts/export_build_constraints.sh | 2 ++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index b9dfed5..044da5c 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,12 @@ uv build --all-packages -b /tmp/build-constraints.txt `export_build_constraints.sh` writes pinned protobuf codegen dependency versions from `uv.lock` so isolated `uv build` does not re-resolve newer Hatch hook dependencies. +During development, `uv sync` also runs protobuf codegen for `sync-tooling-msgs` (Hatch hook). +Workspace `[tool.uv] build-constraint-dependencies` in `pyproject.toml` keeps that codegen aligned +with the locked runtime `protobuf` version. When bumping `protobuf` or related packages in +`uv.lock`, update `build-constraint-dependencies` to the same pins (or run +`scripts/export_build_constraints.sh` and copy the versions). + This will generate a `dist` directory with the built packages, and the `dist/*.whl` files can be installed using `pip`: diff --git a/scripts/export_build_constraints.sh b/scripts/export_build_constraints.sh index 4828c3c..86bee16 100755 --- a/scripts/export_build_constraints.sh +++ b/scripts/export_build_constraints.sh @@ -37,3 +37,5 @@ if ! grep -q '^types-protobuf==' "$tmp"; then fi sort -u "$tmp" >"$out" + +# Keep [tool.uv] build-constraint-dependencies in pyproject.toml aligned with this output.