in modular_api/services/install_service.py [0:0]
def extract_module_requirements_setup_py(module_path: str) -> list[str]:
"""
Extracts the dependencies from the setup.py file
:param module_path: path to the setup.py file
:return: a list of strings, where each string represents a dependency
"""
# get dependencies for module to be installed
module_dependencies = []
with open(module_path) as module_file:
parsed = ast.parse(module_file.read())
for node in parsed.body:
if not isinstance(node, ast.Expr):
continue
if not isinstance(node.value, ast.Call):
continue
if node.value.func.id != "setup":
continue
for keyword in node.value.keywords:
if keyword.arg == "install_requires":
module_dependencies = ast.literal_eval(keyword.value)
return module_dependencies