-
Couldn't load subscription status.
- Fork 318
[http-client-python] Preserve custom fields when migrating from setup.py to pyproject.toml #8673
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?
Conversation
- 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]>
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Outdated
Show resolved
Hide resolved
...tp-client-python/generator/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Show resolved
Hide resolved
packages/http-client-python/generator/test/unittests/test_setup_migration.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/test/unittests/test_setup_migration.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/test/unittests/test_setup_migration.py
Show resolved
Hide resolved
packages/http-client-python/generator/test/unittests/test_setup_migration.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/test/unittests/test_setup_migration.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/test/unittests/test_setup_migration.py
Outdated
Show resolved
Hide resolved
- 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]>
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Outdated
Show resolved
Hide resolved
...tp-client-python/generator/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2
Show resolved
Hide resolved
...tp-client-python/generator/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2
Show resolved
Hide resolved
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/test/unittests/test_setup_migration.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/test/unittests/test_setup_migration.py
Outdated
Show resolved
Hide resolved
- 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]>
|
All changed packages have been documented.
Show changes
|
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]>
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/test/unittests/test_setup_migration.py
Outdated
Show resolved
Hide resolved
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]>
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Outdated
Show resolved
Hide resolved
packages/http-client-python/generator/pygen/codegen/serializers/general_serializer.py
Outdated
Show resolved
Hide resolved
…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]>
| params["KEEP_FIELDS"]["project.keywords"].update(existing_keywords) | ||
|
|
||
| # Keep project URLs | ||
| if "urls" in loaded_pyproject_toml["project"]: |
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.
Add test in autorest.python PR to check additional project.urls are kept
Summary
Successfully implemented automatic migration of fields from setup.py to pyproject.toml when generating Python SDKs.
Changes Completed
_keep_setuppy_fields()method to parse setup.py fieldsserialize_package_file()to accept setup.py contentLatest Changes
Fields Migrated from setup.py
✅ Dependencies - Custom dependencies preserved, tracked deps with higher versions update VERSION_MAP
⚠️ PACKAGE_PPRINT_NAME - Warning logged if mismatched
✅ 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)
Testing
💡 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.