Skip to content

feat(gapic-generator): add pure-python package initialization and versioning codegen#17639

Draft
ohmayr wants to merge 1 commit into
feature/codegen-writerfrom
feature/codegen-package-init
Draft

feat(gapic-generator): add pure-python package initialization and versioning codegen#17639
ohmayr wants to merge 1 commit into
feature/codegen-writerfrom
feature/codegen-package-init

Conversation

@ohmayr

@ohmayr ohmayr commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This PR introduces PackageInitGenerator and PurePythonEngine, migrating package initialization and versioning file generation (gapic_version.py and PEP 561 py.typed marker files) from Jinja templates (.j2) to pure-Python code generation. The PurePythonEngine acts as an incremental template-free dispatcher, routing migrated file types to pure Python while gracefully falling back to Jinja for un-migrated templates. This change eliminates Jinja rendering overhead for versioning files, includes 100% unit test coverage in tests/unit/codegen/test_package_init.py, and produces zero diff against Bazel golden integration tests.

@ohmayr ohmayr force-pushed the feature/codegen-writer branch from 2c39683 to 7cbcd5a Compare July 7, 2026 02:19
@ohmayr ohmayr force-pushed the feature/codegen-package-init branch from 3e90e85 to f18c5f5 Compare July 7, 2026 02:20

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a template-free, pure-Python code generation engine (PurePythonEngine) and component generators (starting with PackageInitGenerator for gapic_version.py and py.typed files) to bypass Jinja rendering for migrated templates. Feedback on the changes points out an issue in PackageInitGenerator.generate_gapic_version where double curly braces in an f-string are escaped to single curly braces in the output, which breaks the Release Please inline annotation marker. Using quadruple curly braces is suggested to output literal double curly braces.

Comment thread packages/gapic-generator/gapic/codegen/components/package_init.py
@ohmayr ohmayr force-pushed the feature/codegen-writer branch from 7cbcd5a to c8a8ee9 Compare July 7, 2026 04:05
@ohmayr ohmayr force-pushed the feature/codegen-package-init branch from f18c5f5 to 27d9ab3 Compare July 7, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant