fix(python): rewrite generated imports with protoletariat#207
Merged
Conversation
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.
Member
Author
|
Verified by dispatching the standalone Note: the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The protobuf Python plugin emits absolute imports rooted at the proto package:
These do not resolve once the code is packaged under
utxorpc_spec(modules install asutxorpc_spec.utxorpc.*), soimport utxorpc_spec...fails withModuleNotFoundError: No module named 'utxorpc.v1alpha'—utxorpc-spec0.19.x is un-importable.generate.ymlalready had aFix python importsstep, but it used BSDsed -i ''syntax which is invalid on the GNU/Linux runner — it silently never applied.Fix
Replace the sed hack with protoletariat, which rewrites proto-generated imports to relative imports by inspecting the FileDescriptorSet — location-independent and correct for both
v1alphaandv1beta.--exclude-google-importsleaves the well-known-type imports alone.Also adds an import smoke-test (v1alpha + v1beta) so an un-importable package can't ship silently again.
Follow-up
Needs a new
specrelease (v0.19.2) to republish a workingutxorpc-spec; then python-sdk#9 bumps to it.