Skip to content

[http-client-python] add pyproject toml#7829

Merged
swathipil merged 52 commits intomicrosoft:mainfrom
swathipil:http-client-python/add-pyproject-toml
Aug 4, 2025
Merged

[http-client-python] add pyproject toml#7829
swathipil merged 52 commits intomicrosoft:mainfrom
swathipil:http-client-python/add-pyproject-toml

Conversation

@swathipil
Copy link
Member

@swathipil swathipil commented Jul 3, 2025

fix #7975
Changes to http-client-python:

  • Automatically generate with pyproject.toml instead of setup.py
  • Added an additional emitter option keep-setup-py to keep the existing setup.py. The basic-setup-py option can continue to be used to generate a basic setup.py file.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2025

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

@typespec/http-client-python - feature ✏️

Adding pyproject.toml generation and optional keep-setup-py flag

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jul 3, 2025

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@swathipil swathipil requested a review from Copilot July 3, 2025 23:09
Copy link
Contributor

Copilot AI left a 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 existing pyproject.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 the readme line, which will produce invalid TOML. Add a line break so readme = ... appears on its own line.
{% endif %}readme = {file = ["README.md"], content-type = "text/markdown"}

@swathipil swathipil requested review from iscai-msft and lmazuel July 3, 2025 23:51
@swathipil swathipil requested a review from msyyc July 30, 2025 23:06
@msyyc msyyc added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Aug 1, 2025
@msyyc
Copy link
Contributor

msyyc commented Aug 4, 2025

@iscai-msft PR approved. Please hold on release for typespec-python if after the PR merged since I need some time to adjust the generation scripts of SDK repo.

@swathipil swathipil marked this pull request as ready for review August 4, 2025 16:07
@swathipil swathipil added this pull request to the merge queue Aug 4, 2025
Merged via the queue into microsoft:main with commit 3d6e6e5 Aug 4, 2025
37 checks passed
@swathipil swathipil deleted the http-client-python/add-pyproject-toml branch August 4, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[python][feature] add pyproject.toml as default packaging file

3 participants