[python] Add buildSystem option to support hatchling#23483
Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom Apr 9, 2026
Merged
[python] Add buildSystem option to support hatchling#23483wing328 merged 2 commits intoOpenAPITools:masterfrom
wing328 merged 2 commits intoOpenAPITools:masterfrom
Conversation
Allow users to choose between setuptools (default) and hatchling as the build system in generated pyproject.toml files. The buildSystem option can be set to 'hatchling' to generate projects using hatchling instead of setuptools. - Add BUILD_SYSTEM constant and CLI option to PythonClientCodegen - Update pyproject.mustache template to conditionally use hatchling or setuptools - Add tests to verify both buildSystem configurations work correctly - Update python generator documentation with buildSystem option Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Member
|
please follow step 3 to fix https://github.com/OpenAPITools/openapi-generator/actions/runs/24123989745/job/70386099027?pr=23483 |
Member
|
cc @cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10) |
Contributor
Author
|
Thanks for checking my PR. |
Member
|
python tests (with buildSystem set to hatchling) passed via #23502 |
6 tasks
Member
|
FYI. Merged #23502 to include a test |
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.
Summary
Adds a new
buildSystemCLI option to the Python generator that allows users to choose betweensetuptools(default) andhatchlingas the build backend for generatedpyproject.tomlfiles.Motivation
When using the Python generator within a uv workspace that uses hatchling as the default build system, the generated projects using setuptools can cause compatibility issues. Specifically, when running mypy across the workspace, import errors occur in the generated project modules due to the mismatch in build system configurations.
This option allows generated projects to match the build system used by other projects in the workspace, ensuring consistent behavior and avoiding import resolution issues when running tools like mypy across the entire workspace.
Changes
BUILD_SYSTEMconstant toPythonClientCodegenbuildSystemCLI option with default value "setuptools"pyproject.mustachetemplate to conditionally output hatchling or setuptools based on the optionTest plan
🤖 Generated with Claude Code