1- import ast
21import requests
2+
3+ try :
4+ import tomllib
5+ except ModuleNotFoundError :
6+ import tomli as tomllib
7+
38from packaging .requirements import Requirement
49from 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
2119def list_versions (package_name ):
@@ -31,8 +29,8 @@ def is_major_update(previous, latest):
3129
3230
3331def 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