From 96692509511ad1847796037e2e5a8e5d45562b43 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 20 Oct 2022 10:13:40 +0800 Subject: [PATCH 1/8] Update swagger_to_sdk_config_autorest.json --- swagger_to_sdk_config_autorest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swagger_to_sdk_config_autorest.json b/swagger_to_sdk_config_autorest.json index acef8f892b1e..8170bb96d6e9 100644 --- a/swagger_to_sdk_config_autorest.json +++ b/swagger_to_sdk_config_autorest.json @@ -2,7 +2,7 @@ "meta": { "autorest_options": { "version": "3.9.2", - "use": ["@autorest/python@6.1.11", "@autorest/modelerfour@4.24.3"], + "use": ["@autorest/python@6.2.0", "@autorest/modelerfour@4.24.3"], "python": "", "sdkrel:python-sdks-folder": "./sdk/.", "version-tolerant": false From 9d3d777674faf3fbc4ea46eaf831381a3f5957e0 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 20 Oct 2022 10:15:17 +0800 Subject: [PATCH 2/8] Update swagger_to_sdk_config_autorest.json --- swagger_to_sdk_config_autorest.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/swagger_to_sdk_config_autorest.json b/swagger_to_sdk_config_autorest.json index 8170bb96d6e9..2511a88bc17b 100644 --- a/swagger_to_sdk_config_autorest.json +++ b/swagger_to_sdk_config_autorest.json @@ -5,7 +5,9 @@ "use": ["@autorest/python@6.2.0", "@autorest/modelerfour@4.24.3"], "python": "", "sdkrel:python-sdks-folder": "./sdk/.", - "version-tolerant": false + "version-tolerant": false, + "include-x-ms-examples-original-file": true, + "generate-sample": true }, "advanced_options": { "create_sdk_pull_requests": true, From fe2dc44163476ccf07e1ee4ae7aadaccdbfca5b8 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 26 Oct 2022 10:24:03 +0800 Subject: [PATCH 3/8] Update swagger_to_sdk_config_autorest.json --- swagger_to_sdk_config_autorest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swagger_to_sdk_config_autorest.json b/swagger_to_sdk_config_autorest.json index 2511a88bc17b..0ec878e2d9e4 100644 --- a/swagger_to_sdk_config_autorest.json +++ b/swagger_to_sdk_config_autorest.json @@ -2,7 +2,7 @@ "meta": { "autorest_options": { "version": "3.9.2", - "use": ["@autorest/python@6.2.0", "@autorest/modelerfour@4.24.3"], + "use": ["@autorest/python@6.2.1", "@autorest/modelerfour@4.24.3"], "python": "", "sdkrel:python-sdks-folder": "./sdk/.", "version-tolerant": false, From e935a60e38ed7ec46df3dfa5c6ea1f876588895e Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 26 Oct 2022 10:27:53 +0800 Subject: [PATCH 4/8] Update setup.py --- tools/azure-sdk-tools/packaging_tools/templates/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/azure-sdk-tools/packaging_tools/templates/setup.py b/tools/azure-sdk-tools/packaging_tools/templates/setup.py index 2c9e1ca3511d..9dd066fd1b84 100644 --- a/tools/azure-sdk-tools/packaging_tools/templates/setup.py +++ b/tools/azure-sdk-tools/packaging_tools/templates/setup.py @@ -80,6 +80,7 @@ {%- endif %} {%- if need_azuremgmtcore %} 'azure-mgmt-core>=1.3.2,<2.0.0', + "typing_extensions>=4.3.0; python_version<'3.8.0'", {%- endif %} ], python_requires=">=3.7" From a296f153d463e8511c109c21945bbf6a7d413c24 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Wed, 26 Oct 2022 11:15:53 +0800 Subject: [PATCH 5/8] optimize dependency --- scripts/auto_release/main.py | 27 ++++++++++--------- .../packaging_tools/templates/setup.py | 10 +++---- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index f285528e5e08..eddd02563ee6 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -379,17 +379,21 @@ def check_changelog_file(self): self.edit_changelog() @staticmethod - def get_need_dependency(): + def get_need_dependency() -> List[str]: template_path = Path('tools/azure-sdk-tools/packaging_tools/templates/setup.py') + items = ["msrest", "azure-mgmt-core", "typing_extensions"] with open(template_path, 'r') as fr: content = fr.readlines() - for line in content: - if 'msrest>' in line: - target_msrest = line.strip().strip(',').strip('\'') - yield target_msrest - if 'azure-mgmt-core' in line: - target_mgmt_core = line.strip().strip(',').strip('\'') - yield target_mgmt_core + dependencies = [] + for i in range(len(content)): + if "install_requires" not in content[i]: + continue + for j in range(i, len(content)): + for item in items: + if item in content[i]: + dependencies.append(content[i].strip().strip(',').strip('\"')) + break + return dependencies @staticmethod def insert_line_num(content: List[str]) -> int: @@ -418,10 +422,9 @@ def edit_ci_file(content: List[str]): print_exec('git add shared_requirements.txt') def check_ci_file(self): - # eg: target_msrest = 'msrest>=0.6.21', target_mgmt_core = 'azure-mgmt-core>=1.3.0,<2.0.0' - target_msrest, target_mgmt_core = list(self.get_need_dependency()) - self.check_ci_file_proc(target_msrest) - self.check_ci_file_proc(target_mgmt_core) + # eg: 'msrest>=0.6.21', 'azure-mgmt-core>=1.3.0,<2.0.0' + for item in self.get_need_dependency(): + self.check_ci_file_proc(item) def check_dev_requirement(self): file = Path(f'sdk/{self.sdk_folder}/azure-mgmt-{self.package_name}/dev_requirements.txt') diff --git a/tools/azure-sdk-tools/packaging_tools/templates/setup.py b/tools/azure-sdk-tools/packaging_tools/templates/setup.py index 9dd066fd1b84..f76c2cca31f1 100644 --- a/tools/azure-sdk-tools/packaging_tools/templates/setup.py +++ b/tools/azure-sdk-tools/packaging_tools/templates/setup.py @@ -70,16 +70,16 @@ 'pytyped': ['py.typed'], }, install_requires=[ - 'msrest>=0.7.1', + "msrest>=0.7.1", {%- if need_msrestazure %} - 'msrestazure>=0.4.32,<2.0.0', + "msrestazure>=0.4.32,<2.0.0", {%- endif %} - 'azure-common~=1.1', + "azure-common~=1.1", {%- if need_azurecore %} - 'azure-core>=1.24.0,<2.0.0', + "azure-core>=1.24.0,<2.0.0", {%- endif %} {%- if need_azuremgmtcore %} - 'azure-mgmt-core>=1.3.2,<2.0.0', + "azure-mgmt-core>=1.3.2,<2.0.0", "typing_extensions>=4.3.0; python_version<'3.8.0'", {%- endif %} ], From 1c91ac85aa5d6dd49759f76acaac269d1edfbc0c Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Wed, 26 Oct 2022 11:43:48 +0800 Subject: [PATCH 6/8] optimize dependency --- scripts/auto_release/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index eddd02563ee6..dce295aac005 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -390,7 +390,7 @@ def get_need_dependency() -> List[str]: continue for j in range(i, len(content)): for item in items: - if item in content[i]: + if item in content[j]: dependencies.append(content[i].strip().strip(',').strip('\"')) break return dependencies From 61b6bf80b753941a75d7cb5747822d838efdecb5 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Wed, 26 Oct 2022 11:53:09 +0800 Subject: [PATCH 7/8] optimize dependency --- scripts/auto_release/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index dce295aac005..0c07a232b09a 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -391,7 +391,7 @@ def get_need_dependency() -> List[str]: for j in range(i, len(content)): for item in items: if item in content[j]: - dependencies.append(content[i].strip().strip(',').strip('\"')) + dependencies.append(content[j].strip().strip(',').strip('\"')) break return dependencies From 685de61ca737a4add27f5a5825ef01ea739a7a94 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Wed, 26 Oct 2022 13:03:34 +0800 Subject: [PATCH 8/8] optimize dependency --- scripts/auto_release/main.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index 0c07a232b09a..9e7e886ddff3 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -381,7 +381,7 @@ def check_changelog_file(self): @staticmethod def get_need_dependency() -> List[str]: template_path = Path('tools/azure-sdk-tools/packaging_tools/templates/setup.py') - items = ["msrest", "azure-mgmt-core", "typing_extensions"] + items = ["msrest>", "azure-mgmt-core", "typing_extensions"] with open(template_path, 'r') as fr: content = fr.readlines() dependencies = [] @@ -408,15 +408,14 @@ def insert_line_num(content: List[str]) -> int: def check_ci_file_proc(self, dependency: str): def edit_ci_file(content: List[str]): new_line = f'#override azure-mgmt-{self.package_name} {dependency}' - dependency_name = dependency.split('>')[0] + dependency_name = re.compile("[a-zA-Z-_]*").findall(dependency)[0] for i in range(len(content)): if new_line in content[i]: return if f'azure-mgmt-{self.package_name} {dependency_name}' in content[i]: content[i] = new_line + '\n' return - prefix = '' if '\n' in content[-1] else '\n' - content.insert(self.insert_line_num(content), prefix + new_line + '\n') + content.insert(self.insert_line_num(content), new_line + '\n') modify_file(str(Path('shared_requirements.txt')), edit_ci_file) print_exec('git add shared_requirements.txt')