From 467e6090836e0a37d44cab208de430554320b99f Mon Sep 17 00:00:00 2001 From: Santiago Date: Wed, 20 May 2026 14:29:59 -0300 Subject: [PATCH] fix(python): rewrite generated imports with protoletariat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The protobuf Python plugin emits absolute imports rooted at the proto package (from utxorpc.v1alpha...), which fail once the code is packaged under utxorpc_spec — making utxorpc-spec un-importable. The previous sed step used BSD 'sed -i ' syntax and silently no-op'd on the GNU/Linux runner. Replace it with protoletariat, which rewrites proto-generated imports to relative imports (location-independent, both v1alpha and v1beta), and add an import smoke-test so a broken package cannot ship again. --- .github/workflows/generate.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index ea96cb2..0aeaec4 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -70,10 +70,26 @@ jobs: - name: Generate dotnet v1beta run: buf generate --template buf.gen.dotnet.v1beta.yaml + # The protobuf Python plugin emits absolute imports rooted at the proto + # package (e.g. `from utxorpc.v1alpha...`), which do not resolve once the + # code is packaged under `utxorpc_spec`. protoletariat rewrites the + # proto-generated imports to relative imports so the single utxorpc-spec + # package works regardless of where it is mounted. - name: Fix python imports - run: - find gen/python/utxorpc_spec -type f -exec sed -i '' 's@from - utxorpc@from utxorpc_spec.utxorpc@g' {} \; + run: | + pipx install protoletariat + protol \ + --create-package \ + --in-place \ + --exclude-google-imports \ + --python-out gen/python/utxorpc_spec \ + buf proto + + - name: Smoke-test python imports + run: | + pip install --quiet protobuf grpcio + cd gen/python + python -c "import utxorpc_spec.utxorpc.v1alpha.sync.sync_pb2, utxorpc_spec.utxorpc.v1beta.sync.sync_pb2; print('python import OK')" - name: Create codegen artifact uses: actions/upload-artifact@v4