Skip to content
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

Update autorest.python to 6.2.1 for new feature --generate-sample #26940

Merged
merged 9 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions scripts/auto_release/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[j]:
dependencies.append(content[j].strip().strip(',').strip('\"'))
break
return dependencies

@staticmethod
def insert_line_num(content: List[str]) -> int:
Expand All @@ -404,24 +408,22 @@ 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')

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')
Expand Down
6 changes: 4 additions & 2 deletions swagger_to_sdk_config_autorest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"meta": {
"autorest_options": {
"version": "3.9.2",
"use": ["@autorest/python@6.1.11", "@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
"version-tolerant": false,
"include-x-ms-examples-original-file": true,
"generate-sample": true
},
"advanced_options": {
"create_sdk_pull_requests": true,
Expand Down
11 changes: 6 additions & 5 deletions tools/azure-sdk-tools/packaging_tools/templates/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,17 @@
'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 %}
],
python_requires=">=3.7"
Expand Down