You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Smithy Python currently generates Python clients with the Java-based code generator in codegen. Contributing to it requires a JDK, Gradle, and Java. This issue tracks replacing it with smithy-python, a code generator written in Python and distributed as a Python package. It follows the discussion in aws/aws-sdk-python#8.
Background: The smithy-ruby team converted their generator from Java to Ruby, so this is not a new idea for a Smithy generator.
Approach
Smithy's run plugin invokes an external program during a build, writing the projected model to it as a JSON AST on standard input. This allows us to write the code generator in Python and still integrate with a standard smithy build. Design documentation lives under designs/codegen, starting with an overview and the CLI contract proposed in #744. Follow-up PRs add a page for each area they implement.
Important
The Java generator stays authoritative for the whole migration. Before cutting any published artifact over, we will re-evaluate the Java generator's feature set as it stands then and confirm the Python generator covers all of it, so the cutover does not regress a customer.
Customer Experience
Installing the generator is a Python tool install. No JDK, Gradle, or Maven coordinates.
In smithy-build.json it is a run plugin. Smithy sends the model on standard input and the generator writes to the plugin's output directory, so --model and --output are not needed:
Customizing generation becomes a Python task too. Protocols and platform behavior are contributed through the smithy_python.codegen.plugins entry-point group instead of a Java PythonIntegration on the Gradle classpath.
Required Changes
Add experimental Python codegen CLI scaffold #744 adds the smithy-python package and its CLI: generate client and generate types, run plugin and direct invocation, and an error hierarchy separating invocation errors from I/O and generation failures.
Symbol provider mapping shape IDs to Python modules and names, with prelude collisions and aliasing.
Writer with import management, CommonMark to docstring conversion, deterministic ordering, and atomic writes.
Schema generation, including recursive schemas.
Structures, unions, enums, intEnums, lists, and maps, with defaults, nullability, and error correction.
Config and client generation, with dedicated input and output structures per operation.
Plugin system: entry-point discovery, topological ordering, model preprocessing, symbol provider decoration, and code sections.
Protocol generators for restJson1, awsJson1_0, awsJson1_1, and awsQuery, plus generated HTTP protocol tests.
Auth scheme resolver generation and httpApiKeyAuth.
AWS integrations for service ID, user agent, identity, and regional endpoints, plus the DynamoDB retry and API Gateway customizations.
Package setup generation for pyproject.toml, README, and runtime dependency constraints.
Post-processing with ruff format and opt-in ruff check.
Settings parity with PythonSettings and the types plugin settings.
Publishing smithy-python to PyPI.
The python-native-codegen-poc branch covers most of that end to end and implements the AWS customizations as Python plugins. It is a reference for the end state, not a merge candidate. Merged work is being split into PRs stacked on #744.
Completion Criteria
A parity review confirms the Python generator covers the Java generator's features at cutover, with any gap closed or accepted in writing.
smithy-python generates the clients published in aws/aws-sdk-python.
Generated packages pass the same protocol and integration tests as the Java path.
Contributing a codegen change requires only a Python toolchain.
codegen is removed.
If a specific protocol, trait, or customization matters to you, please comment so it gets ordered correctly.
Summary
Smithy Python currently generates Python clients with the Java-based code generator in
codegen. Contributing to it requires a JDK, Gradle, and Java. This issue tracks replacing it withsmithy-python, a code generator written in Python and distributed as a Python package. It follows the discussion in aws/aws-sdk-python#8.Background: The smithy-ruby team converted their generator from Java to Ruby, so this is not a new idea for a Smithy generator.
Approach
Smithy's
runplugin invokes an external program during a build, writing the projected model to it as a JSON AST on standard input. This allows us to write the code generator in Python and still integrate with a standardsmithy build. Design documentation lives underdesigns/codegen, starting with an overview and the CLI contract proposed in #744. Follow-up PRs add a page for each area they implement.Important
The Java generator stays authoritative for the whole migration. Before cutting any published artifact over, we will re-evaluate the Java generator's feature set as it stands then and confirm the Python generator covers all of it, so the cutover does not regress a customer.
Customer Experience
Installing the generator is a Python tool install. No JDK, Gradle, or Maven coordinates.
uv tool install smithy-pythonGenerating a client from a model on disk:
In
smithy-build.jsonit is arunplugin. Smithy sends the model on standard input and the generator writes to the plugin's output directory, so--modeland--outputare not needed:{ "version": "1.0", "sources": ["model"], "projections": { "client": { "plugins": { "run::python-client": { "command": [ "smithy-python", "generate", "client", "--package", "weather", "--package-version", "0.0.1" ] } } } } }Customizing generation becomes a Python task too. Protocols and platform behavior are contributed through the
smithy_python.codegen.pluginsentry-point group instead of a JavaPythonIntegrationon the Gradle classpath.Required Changes
smithy-pythonpackage and its CLI:generate clientandgenerate types,runplugin and direct invocation, and an error hierarchy separating invocation errors from I/O and generation failures.applystatements resolved, and generation is scoped to the resolved service's closure.intEnums, lists, and maps, with defaults, nullability, and error correction.restJson1,awsJson1_0,awsJson1_1, andawsQuery, plus generated HTTP protocol tests.httpApiKeyAuth.pyproject.toml, README, and runtime dependency constraints.ruff formatand opt-inruff check.PythonSettingsand the types plugin settings.smithy-pythonto PyPI.The python-native-codegen-poc branch covers most of that end to end and implements the AWS customizations as Python plugins. It is a reference for the end state, not a merge candidate. Merged work is being split into PRs stacked on #744.
Completion Criteria
smithy-pythongenerates the clients published in aws/aws-sdk-python.codegenis removed.If a specific protocol, trait, or customization matters to you, please comment so it gets ordered correctly.