Skip to content

[python] Add buildSystem option to support hatchling#23483

Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom
tughril:feature/python-buildystem
Apr 9, 2026
Merged

[python] Add buildSystem option to support hatchling#23483
wing328 merged 2 commits intoOpenAPITools:masterfrom
tughril:feature/python-buildystem

Conversation

@tughril
Copy link
Copy Markdown
Contributor

@tughril tughril commented Apr 8, 2026

Summary

Adds a new buildSystem CLI option to the Python generator that allows users to choose between setuptools (default) and hatchling as the build backend for generated pyproject.toml files.

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

  • Add BUILD_SYSTEM constant to PythonClientCodegen
  • Add buildSystem CLI option with default value "setuptools"
  • Update pyproject.mustache template to conditionally output hatchling or setuptools based on the option
  • Add comprehensive tests for both buildSystem configurations
  • Update documentation for the new option

Test plan

  • ✅ testDefaultBuildSystemSetuptools - Verifies default setuptools configuration
  • ✅ testBuildSystemHatchling - Verifies hatchling configuration works when specified

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

@wing328
Copy link
Copy Markdown
Member

wing328 commented Apr 8, 2026

@wing328
Copy link
Copy Markdown
Member

wing328 commented Apr 8, 2026

cc @cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10)

@tughril
Copy link
Copy Markdown
Contributor Author

tughril commented Apr 8, 2026

Thanks for checking my PR.

@wing328
Copy link
Copy Markdown
Member

wing328 commented Apr 9, 2026

python tests (with buildSystem set to hatchling) passed via #23502

@wing328 wing328 merged commit 950cf38 into OpenAPITools:master Apr 9, 2026
15 checks passed
@wing328
Copy link
Copy Markdown
Member

wing328 commented Apr 9, 2026

FYI. Merged #23502 to include a test

@tughril tughril deleted the feature/python-buildystem branch April 10, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants