Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

fix logic about which scenario to add msrest as dependency
2 changes: 1 addition & 1 deletion packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTYxODM0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.20.3.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTYxODM5OC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.20.3.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ requires-python = ">=3.9"
keywords = ["azure", "azure sdk"]

dependencies = [
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"azure.mgmt.test": ["py.typed"],
},
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,8 @@
#
# --------------------------------------------------------------------------

import unittest
import subprocess
import sys
import isodate
import tempfile
import json
from uuid import uuid4
from datetime import date, datetime, timedelta
import os
from datetime import timedelta
from os.path import dirname, pardir, join, realpath

from azure.core.exceptions import DeserializationError
Expand Down Expand Up @@ -76,3 +69,28 @@ def test_operation_groups(self):
from bodyduration.operations._duration_operations import DurationOperations as DurationOperationsPy2

assert DurationOperations == DurationOperationsPy2

def test_setup_py_requirements(self):
# this file is generated, so we can basic check on it
# We want to make sure "isodate" is a dependency and not "msrest"
setup_path = realpath(
join(
dirname(realpath(__file__)),
"..",
"Expected",
"AcceptanceTests",
"AzureBodyDuration",
"setup.py",
)
)
# Super ugly, but I don't want to write a parser for a setup.py
with open(setup_path, "r") as setup_file:
content = setup_file.read()

# Let's just check the install_requires is what we expect
# We can't use ast, since it's not abstract syntax tree, it's just text.
# Let's find the install_requires
install_requires_part = content[content.find("install_requires") :]
# This is very fragile, but for a test on generated code, that's what we want
assert "isodate" in install_requires_part
assert "msrest" not in install_requires_part
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-core>=1.35.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-core>=1.35.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-core>=1.35.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-core>=1.35.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-core>=1.35.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ requires-python = ">=3.9"
keywords = ["azure", "azure sdk"]

dependencies = [
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ requires-python = ">=3.9"
keywords = ["azure", "azure sdk"]

dependencies = [
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ requires-python = ">=3.9"
keywords = ["azure", "azure sdk"]

dependencies = [
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-core>=1.35.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-mgmt-core>=1.6.0",
"typing-extensions>=4.6.0",
],
Expand Down
1 change: 1 addition & 0 deletions packages/autorest.python/test/unittests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ azure-mgmt-core==1.6.0
-e ../../samples/specification/azure-mgmt-test/test/azure-mgmt-test
-e ../../samples/specification/azure-mgmt-pyproject/test/azure-mgmt-pyproject
-e ../../samples/specification/azure-test/test/azure-test
-e ../../samples/specification/management/generated
56 changes: 54 additions & 2 deletions packages/autorest.python/test/unittests/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import re
import tomli
from pathlib import Path


Expand Down Expand Up @@ -61,8 +63,6 @@ def test_package_mode_for_azure_mgmt_test():


def test_package_mode_for_azure_mgmt_pyproject():
import tomli

pyproject = (
Path(__file__).parent.parent.parent
/ "samples/specification/azure-mgmt-pyproject/test/azure-mgmt-pyproject/pyproject.toml"
Expand All @@ -89,3 +89,55 @@ def test_import_azure_mgmt_pyproject():
# just need to check import so that we could make sure the generated code is valid
from azure.mgmt.pyproject import PyprojectMgmtClient
from azure.mgmt.pyproject import operations


def test_pyproject_dependencies():
pyproject = (
Path(__file__).parent.parent.parent
/ "samples/specification/azure-mgmt-pyproject/test/azure-mgmt-pyproject/pyproject.toml"
)
assert pyproject.exists(), "pyproject.toml should exist in the specified path"

with open(pyproject, "rb") as f:
pyproject_data = tomli.load(f)

dependencies = pyproject_data.get("project", {}).get("dependencies", [])
dependencies = [re.split(r"[<>=!]", dep)[0].strip() for dep in dependencies] # Remove version specifiers
assert "isodate" in dependencies
assert "msrest" not in dependencies


def test_setup_py_dependencies():
setup_py_path = (
Path(__file__).parent.parent.parent / "samples/specification/azure-mgmt-test/test/azure-mgmt-test/setup.py"
)
assert setup_py_path.exists()

with open(setup_py_path, "r", encoding="utf-8") as f:
content = f.read()

match = re.search(r"install_requires=\[(.*?)\]", content, re.DOTALL)
assert match
install_requires_str = match.group(1)
install_requires = [req.strip().strip("'\",") for req in install_requires_str.split("\n") if req.strip()]
install_requires = [re.split(r"[<>=!]", dep)[0].strip() for dep in install_requires] # Remove version specifiers

assert "isodate" in install_requires
assert "msrest" not in install_requires


def test_management_setup_py_dependencies():
setup_py_path = Path(__file__).parent.parent.parent / "samples/specification/management/generated/setup.py"
assert setup_py_path.exists()

with open(setup_py_path, "r", encoding="utf-8") as f:
content = f.read()

match = re.search(r"install_requires=\[(.*?)\]", content, re.DOTALL)
assert match
install_requires_str = match.group(1)
install_requires = [req.strip().strip("'\",") for req in install_requires_str.split("\n") if req.strip()]
install_requires = [re.split(r"[<>=!]", dep)[0].strip() for dep in install_requires] # Remove version specifiers

assert "isodate" in install_requires
assert "msrest" not in install_requires
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,28 @@ def test_operation_groups(self):
from additionalproperties.operations._pets_operations import PetsOperations as PetsOperationsPy2

assert PetsOperations == PetsOperationsPy2

def test_setup_py_requirements(self):
# this file is generated, so we can basic check on it
# We want to make sure "isodate" is a dependency and not "msrest"
setup_path = realpath(
join(
dirname(realpath(__file__)),
"..",
"Expected",
"AcceptanceTests",
"AdditionalProperties",
"setup.py",
)
)
# Super ugly, but I don't want to write a parser for a setup.py
with open(setup_path, "r") as setup_file:
content = setup_file.read()

# Let's just check the install_requires is what we expect
# We can't use ast, since it's not abstract syntax tree, it's just text.
# Let's find the install_requires
install_requires_part = content[content.find("install_requires") :]
# This is very fragile, but for a test on generated code, that's what we want
assert "isodate" in install_requires_part
assert "msrest" not in install_requires_part
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-core>=1.35.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-core>=1.35.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-core>=1.35.0",
"typing-extensions>=4.6.0",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
packages=find_packages(),
include_package_data=True,
install_requires=[
"msrest>=0.7.1",
"isodate>=0.6.1",
"azure-core>=1.35.0",
"typing-extensions>=4.6.0",
],
Expand Down
Loading
Loading