Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 6, 2025

Summary

Successfully implemented automatic migration of fields from setup.py to pyproject.toml when generating Python SDKs.

Changes Completed

  • Move setup.py removal to after package file serialization
  • Read both pyproject.toml and setup.py during migration
  • Add _keep_setuppy_fields() method to parse setup.py fields
  • Update serialize_package_file() to accept setup.py content
  • Modify pyproject.toml template for keywords and project.urls
  • Update README.md template to reference pyproject.toml
  • Create comprehensive unit tests (5 tests, all passing)
  • Validate with real-world example (azure-confidentialledger)
  • Address all PR feedback and refactor methods
  • Address additional feedback on logging, URLs, and template
  • Fix test to match updated logging format
  • Preserve project.urls from existing pyproject.toml
  • Simplify multi-word key handling code
  • Move Azure SDK repository URL to KEEP_FIELDS
  • Handle mixed quote styles in setup.py parsing

Latest Changes

  • Added default Azure SDK repository URL to KEEP_FIELDS for Azure flavor packages instead of hardcoding in template
  • Clarified regex comment to show it handles both single and double quotes (already working)
  • Unified URL rendering: all URLs now come from KEEP_FIELDS consistently

Fields Migrated from setup.py

Dependencies - Custom dependencies preserved, tracked deps with higher versions update VERSION_MAP
Keywords - All keywords kept as a set (no duplicates)
Project URLs - All URLs preserved with proper TOML formatting (from both setup.py and pyproject.toml)
⚠️ PACKAGE_PPRINT_NAME - Warning logged if mismatched

Testing

  • All 5 unit tests passing with caplog verification
  • Manual validation confirms proper behavior
  • Template rendering verified with multi-word keys and Azure flavor URLs

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 6, 2025 22:18
- Move setup.py removal to after package file serialization
- Read both pyproject.toml and setup.py during migration
- Add _keep_setuppy_fields() method to parse setup.py
- Merge fields from setup.py into pyproject.toml
- Update templates for keywords, project.urls
- Update README.md reference from setup.py to pyproject.toml

Co-authored-by: swathipil <[email protected]>
- Created test_setup_migration.py with comprehensive tests
- Tests cover dependencies, keywords, URLs extraction
- All tests passing successfully

Co-authored-by: swathipil <[email protected]>
@Copilot Copilot AI changed the title [WIP] [http-client-python] added dependencies are copied over from setup.py to pyproject.toml [http-client-python] Preserve custom fields when migrating from setup.py to pyproject.toml Oct 6, 2025
@Copilot Copilot AI requested a review from swathipil October 6, 2025 22:28
Copilot finished work on behalf of swathipil October 6, 2025 22:28
- Change _keep_pyproject_fields and _keep_setuppy_fields to mutate params
- Initialize params with default keywords {"azure", "azure sdk"}
- Update _keep_setuppy_fields to parse project_urls instead of url
- Log actual dependency version in INFO messages
- Remove duplicate keyword filtering (now handled by set)
- Update pyproject.toml template to always output keywords from KEEP_FIELDS
- Rewrite tests to use caplog for logging verification
- Add test for PACKAGE_PPRINT_NAME warning
- Add test for isodate version update to 100.0.0
- Update test to check project_urls parsing
- Remove test for url field
- All tests passing

Co-authored-by: swathipil <[email protected]>
@Copilot Copilot AI requested a review from swathipil October 6, 2025 23:20
Copilot finished work on behalf of swathipil October 6, 2025 23:20
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Oct 6, 2025
- Move logger import to top of file
- Keep all URLs including Azure SDK URLs
- Add quotes around multi-word keys in project.urls
- Fix template to have single project.urls section
- Update test to use Azure SDK URLs
- Update test comment

Co-authored-by: swathipil <[email protected]>
Copilot finished work on behalf of swathipil October 6, 2025 23:53
@Copilot Copilot AI requested a review from swathipil October 6, 2025 23:53
Copy link
Contributor

github-actions bot commented Oct 7, 2025

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

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

[http-client-python] Preserve custom fields when migrating from setup.py to pyproject.toml

The logging format was changed in c3ccdbd to log the full dependency string
instead of just the name and version. Updated test assertion to match.

Co-authored-by: swathipil <[email protected]>
Copilot finished work on behalf of swathipil October 7, 2025 00:03
swathipil and others added 2 commits October 6, 2025 17:04
Preserve custom fields during migration from setup.py to pyproject.toml for the http-client-python package.
- Add project.urls preservation from existing pyproject.toml
- Simplify multi-word key formatting to single line
- Update test to definitively check for quoted multi-word keys

Co-authored-by: swathipil <[email protected]>
@Copilot Copilot AI requested a review from swathipil October 7, 2025 00:08
Copilot finished work on behalf of swathipil October 7, 2025 00:08
…uotes

- Add default Azure SDK repository URL to KEEP_FIELDS for Azure flavor packages
- Remove separate repository line from template (now unified with custom URLs)
- Update regex comment to clarify it handles both single and double quotes
- All URLs now rendered from KEEP_FIELDS consistently

Co-authored-by: swathipil <[email protected]>
@Copilot Copilot AI requested a review from swathipil October 7, 2025 00:31
Copilot finished work on behalf of swathipil October 7, 2025 00:31
params["KEEP_FIELDS"]["project.keywords"].update(existing_keywords)

# Keep project URLs
if "urls" in loaded_pyproject_toml["project"]:
Copy link
Member

Choose a reason for hiding this comment

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

Add test in autorest.python PR to check additional project.urls are kept

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.

2 participants