Skip to content

Commit 48be295

Browse files
authored
[publish] fix outputfolder of packaging files for arm sdk (#3154)
* add package-mode for test * regenerate * add test case * add changelog * update * update
1 parent 2f594b3 commit 48be295

13 files changed

Lines changed: 195 additions & 39 deletions

File tree

packages/autorest.python/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Release
22

3+
## 6.37.2
4+
5+
### Bug Fixes
6+
7+
- [#3154](https://github.com/Azure/autorest.python/pull/3154) fix outputfolder of packaging files for arm sdk
8+
- [#3154](https://github.com/Azure/autorest.python/pull/3154) Ensure necessary typing imports for internal models
9+
10+
311
## 6.37.1
412

513
### Bug Fixes

packages/autorest.python/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@autorest/python",
3-
"version": "6.37.1",
3+
"version": "6.37.2",
44
"description": "The Python extension for generators in AutoRest.",
55
"scripts": {
66
"start": "node ./scripts/run-python3.js ./scripts/start.py",
@@ -29,7 +29,7 @@
2929
},
3030
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
3131
"dependencies": {
32-
"@typespec/http-client-python": "~0.14.1",
32+
"@typespec/http-client-python": "~0.14.2",
3333
"@autorest/system-requirements": "~1.0.2",
3434
"fs-extra": "~11.2.0",
3535
"tsx": "~4.19.1"

packages/autorest.python/samples/specification/azure-mgmt-test/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace: azure.mgmt.test
1313
package-version: 1.0.0b1
1414
clear-output-folder: true
1515
version-tolerant: false
16+
package-mode: azure-mgmt
1617
```
1718
1819
``` yaml $(python)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Release History
2+
3+
## 1.0.0b1 (1970-01-01)
4+
5+
- Initial version
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) Microsoft Corporation.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include *.md
2+
include LICENSE
3+
include azure/mgmt/test/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
6+
include azure/__init__.py
7+
include azure/mgmt/__init__.py
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Azure Mgmt Test client library for Python
2+
<!-- write necessary description of service -->
3+
4+
## Getting started
5+
6+
### Install the package
7+
8+
```bash
9+
python -m pip install azure-mgmt-test
10+
```
11+
12+
#### Prequisites
13+
14+
- Python 3.9 or later is required to use this package.
15+
- You need an [Azure subscription][azure_sub] to use this package.
16+
- An existing Azure Mgmt Test instance.
17+
18+
#### Create with an Azure Active Directory Credential
19+
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
20+
provide an instance of the desired credential type obtained from the
21+
[azure-identity][azure_identity_credentials] library.
22+
23+
To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip]
24+
25+
After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use.
26+
As an example, [DefaultAzureCredential][default_azure_credential] can be used to authenticate the client:
27+
28+
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
29+
`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`
30+
31+
Use the returned token credential to authenticate the client:
32+
33+
```python
34+
>>> from azure.mgmt.test import AutoRestSwaggerBATArrayService
35+
>>> from azure.identity import DefaultAzureCredential
36+
>>> client = AutoRestSwaggerBATArrayService(endpoint='<endpoint>', credential=DefaultAzureCredential())
37+
```
38+
39+
## Examples
40+
41+
```python
42+
>>> from azure.mgmt.test import AutoRestSwaggerBATArrayService
43+
>>> from azure.identity import DefaultAzureCredential
44+
>>> from azure.core.exceptions import HttpResponseError
45+
46+
>>> client = AutoRestSwaggerBATArrayService(endpoint='<endpoint>', credential=DefaultAzureCredential())
47+
>>> try:
48+
<!-- write test code here -->
49+
except HttpResponseError as e:
50+
print('service responds error: {}'.format(e.response.json()))
51+
52+
```
53+
54+
## Contributing
55+
56+
This project welcomes contributions and suggestions. Most contributions require
57+
you to agree to a Contributor License Agreement (CLA) declaring that you have
58+
the right to, and actually do, grant us the rights to use your contribution.
59+
For details, visit https://cla.microsoft.com.
60+
61+
When you submit a pull request, a CLA-bot will automatically determine whether
62+
you need to provide a CLA and decorate the PR appropriately (e.g., label,
63+
comment). Simply follow the instructions provided by the bot. You will only
64+
need to do this once across all repos using our CLA.
65+
66+
This project has adopted the
67+
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
68+
see the Code of Conduct FAQ or contact opencode@microsoft.com with any
69+
additional questions or comments.
70+
71+
<!-- LINKS -->
72+
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
73+
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
74+
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
75+
[azure_identity_pip]: https://pypi.org/project/azure-identity/
76+
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
77+
[pip]: https://pypi.org/project/pip/
78+
[azure_sub]: https://azure.microsoft.com/free/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-e ../../../tools/azure-sdk-tools
2+
../../core/azure-core
3+
../../identity/azure-identity
4+
../../core/azure-mgmt-core
5+
aiohttp
Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,52 @@
1-
#!/usr/bin/env python
2-
3-
# -------------------------------------------------------------------------
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
43
# Copyright (c) Microsoft Corporation. All rights reserved.
5-
# Licensed under the MIT License. See License.txt in the project root for
6-
# license information.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9+
10+
import os
911
import re
10-
import os.path
11-
from io import open
12-
from setuptools import find_packages, setup
12+
from setuptools import setup, find_packages
13+
1314

14-
# Change the PACKAGE_NAME only to change folder and different name
1515
PACKAGE_NAME = "azure-mgmt-test"
16-
PACKAGE_PPRINT_NAME = "Test Management"
16+
PACKAGE_PPRINT_NAME = "Azure Mgmt Test"
1717

1818
# a-b-c => a/b/c
1919
package_folder_path = PACKAGE_NAME.replace("-", "/")
20-
# a-b-c => a.b.c
21-
namespace_name = PACKAGE_NAME.replace("-", ".")
2220

2321
# Version extraction inspired from 'requests'
24-
with open(
25-
(
26-
os.path.join(package_folder_path, "version.py")
27-
if os.path.exists(os.path.join(package_folder_path, "version.py"))
28-
else os.path.join(package_folder_path, "_version.py")
29-
),
30-
"r",
31-
) as fd:
22+
with open(os.path.join(package_folder_path, "_version.py"), "r") as fd:
3223
version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1)
3324

3425
if not version:
3526
raise RuntimeError("Cannot find version information")
3627

28+
3729
setup(
3830
name=PACKAGE_NAME,
3931
version=version,
40-
description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME),
32+
description="Microsoft Corporation {} Client Library for Python".format(PACKAGE_PPRINT_NAME),
33+
long_description=open("README.md", "r").read(),
4134
long_description_content_type="text/markdown",
4235
license="MIT License",
4336
author="Microsoft Corporation",
4437
author_email="azpysdkhelp@microsoft.com",
45-
url="https://github.com/Azure/azure-sdk-for-python",
46-
keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product
38+
url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk",
39+
keywords="azure, azure sdk",
4740
classifiers=[
4841
"Development Status :: 4 - Beta",
4942
"Programming Language :: Python",
5043
"Programming Language :: Python :: 3 :: Only",
5144
"Programming Language :: Python :: 3",
52-
"Programming Language :: Python :: 3.8",
5345
"Programming Language :: Python :: 3.9",
5446
"Programming Language :: Python :: 3.10",
5547
"Programming Language :: Python :: 3.11",
5648
"Programming Language :: Python :: 3.12",
49+
"Programming Language :: Python :: 3.13",
5750
"License :: OSI Approved :: MIT License",
5851
],
5952
zip_safe=False,
@@ -66,11 +59,13 @@
6659
]
6760
),
6861
include_package_data=True,
62+
package_data={
63+
"azure.mgmt.test": ["py.typed"],
64+
},
6965
install_requires=[
70-
"isodate>=0.6.1",
66+
"msrest>=0.7.1",
67+
"azure-mgmt-core>=1.6.0",
7168
"typing-extensions>=4.6.0",
72-
"azure-common>=1.1",
73-
"azure-mgmt-core>=1.3.2",
7469
],
75-
python_requires=">=3.8",
70+
python_requires=">=3.9",
7671
)

packages/autorest.python/test/unittests/test_samples.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,31 @@ def test_azure_test_import():
1919
from azure.test._generated import operations
2020

2121
from azure.test import CustomizeClient
22+
23+
24+
def test_package_mode_for_azure_mgmt_test():
25+
# check whether samples/specification/azure-mgmt-test/test/azure-mgmt-test contains setup.py/CHANGELOG.md
26+
import os
27+
from pathlib import Path
28+
29+
# Get the path to the samples directory relative to this test file
30+
current_dir = Path(__file__).parent
31+
samples_dir = (
32+
current_dir.parent.parent / "samples" / "specification" / "azure-mgmt-test" / "test" / "azure-mgmt-test"
33+
)
34+
35+
# Check if setup.py exists
36+
setup_py_path = samples_dir / "setup.py"
37+
assert setup_py_path.exists(), f"setup.py not found at {setup_py_path}"
38+
39+
# Check if CHANGELOG.md exists
40+
changelog_path = samples_dir / "CHANGELOG.md"
41+
assert changelog_path.exists(), f"CHANGELOG.md not found at {changelog_path}"
42+
43+
# setup.py shall not exist in inner folder
44+
inner_setup_py_path = samples_dir / "azure/mgmt/test/setup.py"
45+
assert not inner_setup_py_path.exists(), f"setup.py should not exist at {inner_setup_py_path}"
46+
47+
# CHANGELOG.md shall not exist in inner folder
48+
inner_changelog_path = samples_dir / "azure/mgmt/test/CHANGELOG.md"
49+
assert not inner_changelog_path.exists(), f"CHANGELOG.md should not exist at {inner_changelog_path}"

0 commit comments

Comments
 (0)