diff --git a/packages/autorest.python/CHANGELOG.md b/packages/autorest.python/CHANGELOG.md index f0e04282559..7c8b8e2c9ca 100644 --- a/packages/autorest.python/CHANGELOG.md +++ b/packages/autorest.python/CHANGELOG.md @@ -1,5 +1,13 @@ # Release +## 6.37.2 + +### Bug Fixes + +- [#3154](https://github.com/Azure/autorest.python/pull/3154) fix outputfolder of packaging files for arm sdk +- [#3154](https://github.com/Azure/autorest.python/pull/3154) Ensure necessary typing imports for internal models + + ## 6.37.1 ### Bug Fixes diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index 8a5ec4990d5..83ecae09085 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/python", - "version": "6.37.1", + "version": "6.37.2", "description": "The Python extension for generators in AutoRest.", "scripts": { "start": "node ./scripts/run-python3.js ./scripts/start.py", @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md", "dependencies": { - "@typespec/http-client-python": "~0.14.1", + "@typespec/http-client-python": "~0.14.2", "@autorest/system-requirements": "~1.0.2", "fs-extra": "~11.2.0", "tsx": "~4.19.1" diff --git a/packages/autorest.python/samples/specification/azure-mgmt-test/readme.md b/packages/autorest.python/samples/specification/azure-mgmt-test/readme.md index 01ad3adfc31..965e4d1f10a 100644 --- a/packages/autorest.python/samples/specification/azure-mgmt-test/readme.md +++ b/packages/autorest.python/samples/specification/azure-mgmt-test/readme.md @@ -13,6 +13,7 @@ namespace: azure.mgmt.test package-version: 1.0.0b1 clear-output-folder: true version-tolerant: false +package-mode: azure-mgmt ``` ``` yaml $(python) diff --git a/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/CHANGELOG.md b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/CHANGELOG.md new file mode 100644 index 00000000000..628743d283a --- /dev/null +++ b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (1970-01-01) + +- Initial version diff --git a/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/LICENSE b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/LICENSE new file mode 100644 index 00000000000..63447fd8bbb --- /dev/null +++ b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/MANIFEST.in b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/MANIFEST.in new file mode 100644 index 00000000000..30bf1f98f1f --- /dev/null +++ b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/MANIFEST.in @@ -0,0 +1,7 @@ +include *.md +include LICENSE +include azure/mgmt/test/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/mgmt/__init__.py diff --git a/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/README.md b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/README.md new file mode 100644 index 00000000000..25c2ae6694f --- /dev/null +++ b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/README.md @@ -0,0 +1,78 @@ +# Azure Mgmt Test client library for Python + + +## Getting started + +### Install the package + +```bash +python -m pip install azure-mgmt-test +``` + +#### Prequisites + +- Python 3.9 or later is required to use this package. +- You need an [Azure subscription][azure_sub] to use this package. +- An existing Azure Mgmt Test instance. + +#### Create with an Azure Active Directory Credential +To use an [Azure Active Directory (AAD) token credential][authenticate_with_token], +provide an instance of the desired credential type obtained from the +[azure-identity][azure_identity_credentials] library. + +To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip] + +After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use. +As an example, [DefaultAzureCredential][default_azure_credential] can be used to authenticate the client: + +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: +`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET` + +Use the returned token credential to authenticate the client: + +```python +>>> from azure.mgmt.test import AutoRestSwaggerBATArrayService +>>> from azure.identity import DefaultAzureCredential +>>> client = AutoRestSwaggerBATArrayService(endpoint='', credential=DefaultAzureCredential()) +``` + +## Examples + +```python +>>> from azure.mgmt.test import AutoRestSwaggerBATArrayService +>>> from azure.identity import DefaultAzureCredential +>>> from azure.core.exceptions import HttpResponseError + +>>> client = AutoRestSwaggerBATArrayService(endpoint='', credential=DefaultAzureCredential()) +>>> try: + + except HttpResponseError as e: + print('service responds error: {}'.format(e.response.json())) + +``` + +## Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, +see the Code of Conduct FAQ or contact opencode@microsoft.com with any +additional questions or comments. + + +[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ +[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials +[azure_identity_pip]: https://pypi.org/project/azure-identity/ +[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential +[pip]: https://pypi.org/project/pip/ +[azure_sub]: https://azure.microsoft.com/free/ diff --git a/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/dev_requirements.txt b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/dev_requirements.txt new file mode 100644 index 00000000000..05b9717a94f --- /dev/null +++ b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/dev_requirements.txt @@ -0,0 +1,5 @@ +-e ../../../tools/azure-sdk-tools +../../core/azure-core +../../identity/azure-identity +../../core/azure-mgmt-core +aiohttp \ No newline at end of file diff --git a/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/setup.py b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/setup.py index aeb15b72d46..9d8eb7c5e3d 100644 --- a/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/setup.py +++ b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/setup.py @@ -1,59 +1,52 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- +# coding=utf-8 +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + +import os import re -import os.path -from io import open -from setuptools import find_packages, setup +from setuptools import setup, find_packages + -# Change the PACKAGE_NAME only to change folder and different name PACKAGE_NAME = "azure-mgmt-test" -PACKAGE_PPRINT_NAME = "Test Management" +PACKAGE_PPRINT_NAME = "Azure Mgmt Test" # a-b-c => a/b/c package_folder_path = PACKAGE_NAME.replace("-", "/") -# a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open( - ( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py") - ), - "r", -) as fd: +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: raise RuntimeError("Cannot find version information") + setup( name=PACKAGE_NAME, version=version, - description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + description="Microsoft Corporation {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), long_description_content_type="text/markdown", license="MIT License", author="Microsoft Corporation", author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python", - keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", + keywords="azure, azure sdk", classifiers=[ "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -66,11 +59,13 @@ ] ), include_package_data=True, + package_data={ + "azure.mgmt.test": ["py.typed"], + }, install_requires=[ - "isodate>=0.6.1", + "msrest>=0.7.1", + "azure-mgmt-core>=1.6.0", "typing-extensions>=4.6.0", - "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.8", + python_requires=">=3.9", ) diff --git a/packages/autorest.python/test/unittests/test_samples.py b/packages/autorest.python/test/unittests/test_samples.py index aa405a59d46..0f25523d12f 100644 --- a/packages/autorest.python/test/unittests/test_samples.py +++ b/packages/autorest.python/test/unittests/test_samples.py @@ -19,3 +19,31 @@ def test_azure_test_import(): from azure.test._generated import operations from azure.test import CustomizeClient + + +def test_package_mode_for_azure_mgmt_test(): + # check whether samples/specification/azure-mgmt-test/test/azure-mgmt-test contains setup.py/CHANGELOG.md + import os + from pathlib import Path + + # Get the path to the samples directory relative to this test file + current_dir = Path(__file__).parent + samples_dir = ( + current_dir.parent.parent / "samples" / "specification" / "azure-mgmt-test" / "test" / "azure-mgmt-test" + ) + + # Check if setup.py exists + setup_py_path = samples_dir / "setup.py" + assert setup_py_path.exists(), f"setup.py not found at {setup_py_path}" + + # Check if CHANGELOG.md exists + changelog_path = samples_dir / "CHANGELOG.md" + assert changelog_path.exists(), f"CHANGELOG.md not found at {changelog_path}" + + # setup.py shall not exist in inner folder + inner_setup_py_path = samples_dir / "azure/mgmt/test/setup.py" + assert not inner_setup_py_path.exists(), f"setup.py should not exist at {inner_setup_py_path}" + + # CHANGELOG.md shall not exist in inner folder + inner_changelog_path = samples_dir / "azure/mgmt/test/CHANGELOG.md" + assert not inner_changelog_path.exists(), f"CHANGELOG.md should not exist at {inner_changelog_path}" diff --git a/packages/typespec-python/CHANGELOG.md b/packages/typespec-python/CHANGELOG.md index 14e7dcb4776..1b804d37bd7 100644 --- a/packages/typespec-python/CHANGELOG.md +++ b/packages/typespec-python/CHANGELOG.md @@ -1,5 +1,13 @@ # Release +## 0.47.2 + +### Bug Fixes + +- [#3154](https://github.com/Azure/autorest.python/pull/3154) fix outputfolder of packaging files for arm sdk +- [#3154](https://github.com/Azure/autorest.python/pull/3154) Ensure necessary typing imports for internal models + + ## 0.47.1 ### Bug Fixes diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index eab601653d5..c8e6a92b4cb 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -1,6 +1,6 @@ { "name": "@azure-tools/typespec-python", - "version": "0.47.1", + "version": "0.47.2", "author": "Microsoft Corporation", "description": "TypeSpec emitter for Python SDKs", "homepage": "https://github.com/Azure/autorest.python", @@ -67,7 +67,7 @@ "js-yaml": "~4.1.0", "semver": "~7.6.2", "tsx": "~4.19.1", - "@typespec/http-client-python": "~0.14.1", + "@typespec/http-client-python": "~0.14.2", "fs-extra": "~11.2.0" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f73348d8cd..47c5a1105b0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,8 +60,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: ~0.14.1 - version: 0.14.1(iurth4uuk4s6znzuuc7ncenk2q) + specifier: ~0.14.2 + version: 0.14.2(iurth4uuk4s6znzuuc7ncenk2q) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -82,8 +82,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: ~0.14.1 - version: 0.14.1(iurth4uuk4s6znzuuc7ncenk2q) + specifier: ~0.14.2 + version: 0.14.2(iurth4uuk4s6znzuuc7ncenk2q) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -1668,8 +1668,8 @@ packages: peerDependencies: '@typespec/compiler': ^1.2.1 - '@typespec/http-client-python@0.14.1': - resolution: {integrity: sha512-XCBstfoOFPdAZ9479hb6vwtA1h+mkROjo3bBtCh5ITcy9gECvQK6vOLkjrGywmsaBBFRJhHrUI94MxWFAfJwOQ==} + '@typespec/http-client-python@0.14.2': + resolution: {integrity: sha512-5G8uCugt6FNW8pvxog5/oWTdN6SXXhVRu8OBOf6QoPy8gNkeTsNraQz6vRYkyR/VpxnFatUbXfdPmE/vuFKABA==} engines: {node: '>=20.0.0'} peerDependencies: '@azure-tools/typespec-autorest': '>=0.58.0 <1.0.0' @@ -6421,7 +6421,7 @@ snapshots: dependencies: '@typespec/compiler': 1.2.1(@types/node@22.13.17) - '@typespec/http-client-python@0.14.1(iurth4uuk4s6znzuuc7ncenk2q)': + '@typespec/http-client-python@0.14.2(iurth4uuk4s6znzuuc7ncenk2q)': dependencies: '@azure-tools/typespec-autorest': 0.58.0(vddu6w2yloigenmssnpyjivoim) '@azure-tools/typespec-azure-core': 0.58.0(@typespec/compiler@1.2.1(@types/node@22.13.17))(@typespec/http@1.2.1(@typespec/compiler@1.2.1(@types/node@22.13.17))(@typespec/streams@0.72.1(@typespec/compiler@1.2.1(@types/node@22.13.17))))(@typespec/rest@0.72.1(@typespec/compiler@1.2.1(@types/node@22.13.17))(@typespec/http@1.2.1(@typespec/compiler@1.2.1(@types/node@22.13.17))(@typespec/streams@0.72.1(@typespec/compiler@1.2.1(@types/node@22.13.17)))))