From 9f355decd286cbdff71e31c7c52e377972bbb18c Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Mon, 27 Jun 2022 17:49:22 +0800 Subject: [PATCH] Update dpg version (#24986) * update swagger readme.md * update * remove lib --- scripts/quickstart_tooling_dpg/main.py | 29 +---- .../template/CHANGELOG.md | 6 - .../quickstart_tooling_dpg/template/LICENSE | 21 ---- .../template/MANIFEST.in | 7 -- .../quickstart_tooling_dpg/template/README.md | 105 ++++-------------- .../template/__init__.py | 1 - .../template/dev_requirements.txt | 7 -- .../quickstart_tooling_dpg/template/setup.py | 67 ----------- .../template/swagger_README.md | 21 ---- swagger_to_sdk_config_dpg.json | 2 +- 10 files changed, 23 insertions(+), 243 deletions(-) delete mode 100644 scripts/quickstart_tooling_dpg/template/CHANGELOG.md delete mode 100644 scripts/quickstart_tooling_dpg/template/LICENSE delete mode 100644 scripts/quickstart_tooling_dpg/template/MANIFEST.in delete mode 100644 scripts/quickstart_tooling_dpg/template/__init__.py delete mode 100644 scripts/quickstart_tooling_dpg/template/dev_requirements.txt delete mode 100644 scripts/quickstart_tooling_dpg/template/setup.py delete mode 100644 scripts/quickstart_tooling_dpg/template/swagger_README.md diff --git a/scripts/quickstart_tooling_dpg/main.py b/scripts/quickstart_tooling_dpg/main.py index 8b70a4ae0e6b..4e6cb31be0bf 100644 --- a/scripts/quickstart_tooling_dpg/main.py +++ b/scripts/quickstart_tooling_dpg/main.py @@ -4,7 +4,6 @@ import os from jinja2 import Environment, FileSystemLoader from subprocess import check_call -import time from typing import Any import json @@ -69,7 +68,7 @@ def generate_swagger_readme(work_path: str, env: Environment, **kwargs: Any) -> os.makedirs(swagger_path) # render file - template = env.get_template('swagger_README.md') + template = env.get_template('README.md') result = template.render(**kwargs) swagger_readme = swagger_path / Path('README.md') with open(swagger_readme, 'w') as fd: @@ -88,16 +87,9 @@ def build_package(**kwargs) -> None: # prepare template render parameters output_folder = kwargs.get("output_folder") package_name = kwargs.get("package_name") - swagger_readme_output = '../' + package_name.replace('-', '/') - kwargs['swagger_readme_output'] = swagger_readme_output namespace = package_name.replace('-', '.') kwargs['namespace'] = namespace - kwargs['date'] = time.strftime('%Y-%m-%d', time.localtime()) - folder_list = package_name.split('-') - kwargs['folder_first'] = folder_list[0] - kwargs['folder_second'] = folder_list[1] - kwargs['folder_parent'] = Path(output_folder).parts[-2] - kwargs['test_prefix'] = folder_list[-1] + kwargs['test_prefix'] = package_name.split('-')[-1] _LOGGER.info("Build start: %s", package_name) check_parameters(output_folder) @@ -114,24 +106,9 @@ def build_package(**kwargs) -> None: _LOGGER.info(f"generate SDK code with autorest: {autorest_cmd}") check_call(autorest_cmd, shell=True) - # generate necessary file(setup.py, CHANGELOG.md, etc) - work_path = Path(output_folder) - for template_name in env.list_templates(): - _LOGGER.info(f"generate necessary file: {template_name}") - template = env.get_template(template_name) - result = template.render(**kwargs) - # __init__.py is a weird one - if template_name == "__init__.py": - split_package_name = package_name.split("-")[:-1] - for i in range(len(split_package_name)): - init_path = work_path.joinpath(*split_package_name[: i + 1], template_name) - with open(init_path, "w") as fd: - fd.write(result) - elif template_name != 'swagger_README.md': - with open(work_path / template_name, "w") as fd: - fd.write(result) # generate test framework + work_path = Path(output_folder) generate_test_sample(_TEMPLATE_TESTS, work_path / Path('tests'), **kwargs) # generate sample framework diff --git a/scripts/quickstart_tooling_dpg/template/CHANGELOG.md b/scripts/quickstart_tooling_dpg/template/CHANGELOG.md deleted file mode 100644 index fda4f0851bfd..000000000000 --- a/scripts/quickstart_tooling_dpg/template/CHANGELOG.md +++ /dev/null @@ -1,6 +0,0 @@ -# Release History - -## 1.0.0b1 ({{ date }}) - -- Initial version - diff --git a/scripts/quickstart_tooling_dpg/template/LICENSE b/scripts/quickstart_tooling_dpg/template/LICENSE deleted file mode 100644 index b2f52a2bad4e..000000000000 --- a/scripts/quickstart_tooling_dpg/template/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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. diff --git a/scripts/quickstart_tooling_dpg/template/MANIFEST.in b/scripts/quickstart_tooling_dpg/template/MANIFEST.in deleted file mode 100644 index 635079f85b87..000000000000 --- a/scripts/quickstart_tooling_dpg/template/MANIFEST.in +++ /dev/null @@ -1,7 +0,0 @@ -include *.md -include {{ folder_first }}/__init__.py -include {{ folder_first }}/{{ folder_second }}/__init__.py -include LICENSE -recursive-include tests *.py -recursive-include samples *.py *.md -include {{ package_name.replace('-', '/') }}/py.typed diff --git a/scripts/quickstart_tooling_dpg/template/README.md b/scripts/quickstart_tooling_dpg/template/README.md index 660d458d8207..927742cef734 100644 --- a/scripts/quickstart_tooling_dpg/template/README.md +++ b/scripts/quickstart_tooling_dpg/template/README.md @@ -1,87 +1,20 @@ -# {{ package_pprint_name }} client library for Python - - -## _Disclaimer_ - -_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please -refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ - -## Getting started - -### Installating the package - -```bash -python -m pip install {{ package_name }} -``` - -#### Prequisites - -- Python 3.6 or later is required to use this package. -- You need an [Azure subscription][azure_sub] to use this package. -- An existing {{ package_pprint_name }} 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 {{ namespace }} import {{ client_name }} ->>> from azure.identity import DefaultAzureCredential ->>> client = {{ client_name }}(endpoint='', credential=DefaultAzureCredential()) +### Settings + +```yaml +input-file: {{ input_file }} +output-folder: ../ +namespace: {{ namespace }} +package-name: {{ package_name }} +license-header: MICROSOFT_MIT_NO_VERSION +title: {{ client_name }} +package-version: 1.0.0b1 +package-mode: dataplane +package-pprint-name: {{ package_pprint_name }} +{%- if security_scope %} +security: AADToken +security-scopes: {{ security_scope }} +{%- elif security_header_name %} +security: AzureKey +security-header-name: {{ security_header_name }} +{%- endif %} ``` - -## Examples - -```python ->>> from {{ namespace }} import {{ client_name }} ->>> from azure.identity import DefaultAzureCredential ->>> from azure.core.exceptions import HttpResponseError - ->>> client = {{ client_name }}(endpoint='', credential=DefaultAzureCredential()) ->>> try: - - except HttpResponseError as e: - print('service responds error: {}'.format(e.response.json())) - -``` - -## Next steps - -More examples are coming soon... - -## 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/scripts/quickstart_tooling_dpg/template/__init__.py b/scripts/quickstart_tooling_dpg/template/__init__.py deleted file mode 100644 index 8db66d3d0f0f..000000000000 --- a/scripts/quickstart_tooling_dpg/template/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/scripts/quickstart_tooling_dpg/template/dev_requirements.txt b/scripts/quickstart_tooling_dpg/template/dev_requirements.txt deleted file mode 100644 index 8d3c7d8e1144..000000000000 --- a/scripts/quickstart_tooling_dpg/template/dev_requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ --e ../../../tools/azure-devtools --e ../../../tools/azure-sdk-tools -../../core/azure-core -../../identity/azure-identity -aiohttp>=3.0 -typing_extensions>=3.7.2 -asyncio diff --git a/scripts/quickstart_tooling_dpg/template/setup.py b/scripts/quickstart_tooling_dpg/template/setup.py deleted file mode 100644 index 6d2785d6f41c..000000000000 --- a/scripts/quickstart_tooling_dpg/template/setup.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -import os -import re -from setuptools import setup, find_packages - -# Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "{{ package_name }}" -PACKAGE_PPRINT_NAME = "{{ package_pprint_name }}" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") - -# Version extraction inspired from 'requests' -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 {} 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/tree/main/sdk/{{ folder_parent }}/{{ package_name }}", - classifiers=[ - "Development Status :: 4 - Beta", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "License :: OSI Approved :: MIT License", - ], - include_package_data=True, - package_data={ - "pytyped": ["py.typed"], - }, - zip_safe=False, - packages=find_packages( - exclude=[ - # Exclude packages that will be covered by PEP420 or nspkg - "{{ folder_first }}", - "{{ folder_first }}.{{ folder_second }}", - ] - ), - install_requires=[ - "azure-core<2.0.0,>=1.24.0", - "msrest>=0.7.0", - ], - python_requires=">=3.6", -) diff --git a/scripts/quickstart_tooling_dpg/template/swagger_README.md b/scripts/quickstart_tooling_dpg/template/swagger_README.md deleted file mode 100644 index acea17144992..000000000000 --- a/scripts/quickstart_tooling_dpg/template/swagger_README.md +++ /dev/null @@ -1,21 +0,0 @@ -### Settings - -```yaml -input-file: {{ input_file }} -output-folder: {{ swagger_readme_output }} -namespace: {{ namespace }} -package-name: {{ package_name }} -license-header: MICROSOFT_MIT_NO_VERSION -clear-output-folder: true -no-namespace-folders: true -title: {{ client_name }} -version-tolerant: true -package-version: 1.0.0b1 -{%- if security_scope %} -security: AADToken -security-scopes: {{ security_scope }} -{%- elif security_header_name %} -security: AzureKey -security-header-name: {{ security_header_name }} -{%- endif %} -``` diff --git a/swagger_to_sdk_config_dpg.json b/swagger_to_sdk_config_dpg.json index 373db6608830..f797c4f563c6 100644 --- a/swagger_to_sdk_config_dpg.json +++ b/swagger_to_sdk_config_dpg.json @@ -2,7 +2,7 @@ "meta": { "autorest_options": { "version": "3.8.1", - "use": ["@autorest/python@5.19.0", "@autorest/modelerfour@4.23.5"], + "use": ["@autorest/python@6.0.0", "@autorest/modelerfour@4.23.5"], "python": "", "sdkrel:python-sdks-folder": "./sdk/.", "version-tolerant": ""