-
Notifications
You must be signed in to change notification settings - Fork 294
[http-client-python] add pyproject toml #7829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[http-client-python] add pyproject toml #7829
Conversation
All changed packages have been documented.
Show changes
|
You can try these changes here
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces setup.py
with a pyproject.toml
-based build for the Python HTTP client generator, adds a corresponding template and retention logic, and updates related packaging dependencies.
- Added
pyproject.toml.jinja2
template and support in the serializer - Updated serializer to remove
setup.py
, retain existingpyproject.toml
fields, and manage version comparisons - Adjusted
package.json
to include new dependencies for Python client generation
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
packages/http-client-python/package.json | Added new dependencies and reordered existing ones for Python codegen |
generator/pygen/codegen/templates/.../pyproject.toml.jinja2 | Introduced pyproject.toml template for packaging |
generator/pygen/codegen/serializers/general_serializer.py | Added methods to extract and retain pyproject.toml fields, removed setup.py code paths |
generator/pygen/codegen/serializers/init.py | Swapped out setup.py.jinja2 for pyproject.toml.jinja2 , updated regeneration logic |
generator/pygen/init.py | Added remove_file helper to delete setup.py |
cspell.yaml | Added pytyped to the spelling dictionary |
Files not reviewed (1)
- packages/http-client-python/package-lock.json: Language not supported
Comments suppressed due to low confidence (2)
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py:63
- The logic for retaining existing
pyproject.toml
fields isn't covered by tests. Add unit tests for_keep_pyproject_fields
to ensure dependencies and build-tool settings are correctly preserved.
def _keep_pyproject_fields(self, file_path: str) -> dict:
packages/http-client-python/generator/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2:86
- There is no newline between the closing
{% endif %}
and thereadme
line, which will produce invalid TOML. Add a line break soreadme = ...
appears on its own line.
{% endif %}readme = {file = ["README.md"], content-type = "text/markdown"}
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Outdated
Show resolved
Hide resolved
…or apiview src dir pick up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setup.py is deleted and no new pyproject.toml added like https://github.com/Azure/autorest.python/pull/3131/files#diff-e1c1d7e9a7d2d851543131c5429f9d47939fb704078421ebaedd02210b30bcab which seems bug
I notice codegen will generate pyproject.toml instead of setup.py after this PR. What about the existing SDKs? Is it OK when both setup.py and pyproject.toml exist at the same time? Shall we delete the existing setup.py when new pyproject.toml generated in codegen? |
@msyyc - Looking into the bug where pyproject.toml isn't being generated for swagger. For existing SDKs, it should regenerate with pyproject.toml and remove the existing setup.py file. If any existing SDKs need to continue using setup.py for some reason, they can set |
# Keep azure-sdk-build configuration | ||
if "tool" in loaded_pyproject_toml and "azure-sdk-build" in loaded_pyproject_toml["tool"]: | ||
result["KEEP_FIELDS"]["tool.azure-sdk-build"] = loaded_pyproject_toml["tool"]["azure-sdk-build"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swathipil I try to use this PR to regenerate for existing SDKs and find some content of pyproject.toml is deleted like https://github.com/Azure/azure-sdk-for-python/compare/main...msyyc:test-2025-07-22?expand=1

It seems that the logic doesn't work.
# remove setup.py file | ||
if self.code_model.options.get("generate-setup-py") or self.code_model.options.get("basic-setup-py"): | ||
# Write the setup file | ||
if self.code_model.options["basic-setup-py"]: | ||
self.write_file(exec_path / Path("setup.py"), general_serializer.serialize_setup_file()) | ||
else: | ||
self.remove_file(exec_path / Path("setup.py")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swathipil It is not intuitive for the judge logic. It is better like:
if basic-setup-py:
# write setup
elif self.code_model.options.get("generate-setup-py") is False:
# remove setup.py
fix #7975
Changes to http-client-python:
generate-setup-py
to revert to setup.py generation if needed.