MCPcopy
hub / github.com/HKUDS/DeepCode / retrieve_metadata

Function retrieve_metadata

setup.py:15–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14# Retrieving metadata from __init__.py
15def retrieve_metadata():
16 vars2find = ["__author__", "__version__", "__url__"]
17 vars2readme = {}
18
19 # Use definitive path relative to setup.py location
20 init_file_path = os.path.join(os.path.dirname(__file__), "__init__.py")
21
22 with open(init_file_path, encoding="utf-8") as f:
23 for line in f.readlines():
24 for v in vars2find:
25 if line.startswith(v):
26 line = (
27 line.replace(" ", "").replace('"', "").replace("'", "").strip()
28 )
29 vars2readme[v] = line.split("=")[1]
30
31 # Checking if all required variables are found
32 missing_vars = [v for v in vars2find if v not in vars2readme]
33 if missing_vars:
34 raise ValueError(
35 f"Missing required metadata variables in __init__.py: {missing_vars}"
36 )
37
38 return vars2readme
39
40
41# Reading dependencies from requirements.txt

Callers 1

setup.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected