Skip to content

Commit 876d103

Browse files
Update Major Version Checker due to setup removal (#45990)
1 parent 88cc69e commit 876d103

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

sdk/ml/azure-ai-ml/scripts/major_updates.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import ast
21
import requests
2+
3+
try:
4+
import tomllib
5+
except ModuleNotFoundError:
6+
import tomli as tomllib
7+
38
from packaging.requirements import Requirement
49
from packaging.version import Version
510

611

7-
def fetch_dependencies_from_setup(file_path):
8-
with open(file_path, "r") as file:
9-
tree = ast.parse(file.read(), filename=file_path)
12+
def fetch_dependencies_from_pyproject(file_path):
13+
with open(file_path, "rb") as file:
14+
data = tomllib.load(file)
1015

11-
dependencies = []
12-
for node in ast.walk(tree):
13-
if isinstance(node, ast.Call) and getattr(node.func, "id", None) == "setup":
14-
for keyword in node.keywords:
15-
if keyword.arg == "install_requires":
16-
dependencies = [elt.s for elt in keyword.value.elts]
17-
break
18-
return dependencies
16+
return data.get("project", {}).get("dependencies", [])
1917

2018

2119
def list_versions(package_name):
@@ -31,8 +29,8 @@ def is_major_update(previous, latest):
3129

3230

3331
def check_for_major_updates():
34-
setup_file_path = "sdk/ml/azure-ai-ml/setup.py"
35-
deps_list = fetch_dependencies_from_setup(setup_file_path)
32+
pyproject_file_path = "sdk/ml/azure-ai-ml/pyproject.toml"
33+
deps_list = fetch_dependencies_from_pyproject(pyproject_file_path)
3634
deps = [Requirement(line) for line in deps_list if line.strip() and not line.strip().startswith("#")]
3735

3836
with open("updates.txt", "w") as f:

0 commit comments

Comments
 (0)