MCPcopy Index your code
hub / github.com/StackStorm/st2 / fetch_requirements

Function fetch_requirements

st2tests/dist_utils.py:56–107  ·  view source on GitHub ↗

Return a list of requirements and links by parsing the provided requirements file.

(requirements_file_path)

Source from the content-addressed store, hash-verified

54
55
56def fetch_requirements(requirements_file_path):
57 """
58 Return a list of requirements and links by parsing the provided requirements file.
59 """
60 links = []
61 reqs = []
62
63 def _get_link(line):
64 vcs_prefixes = ["git+", "svn+", "hg+", "bzr+"]
65
66 for vcs_prefix in vcs_prefixes:
67 if line.startswith(vcs_prefix) or line.startswith("-e %s" % (vcs_prefix)):
68 req_name = re.findall(".*#egg=(.+)([&|@]).*$", line)
69
70 if not req_name:
71 req_name = re.findall(".*#egg=(.+?)$", line)
72 else:
73 req_name = req_name[0]
74
75 if not req_name:
76 raise ValueError(
77 'Line "%s" is missing "#egg=<package name>"' % (line)
78 )
79
80 link = line.replace("-e ", "").strip()
81 return link, req_name[0]
82 elif vcs_prefix in line and line.count("@") == 2:
83 # PEP 440 direct reference: <package name>@ <url>@version
84 req_name, link = line.split("@", 1)
85 req_name = req_name.strip()
86 link = f"{link.strip()}#egg={req_name}"
87 return link, req_name
88
89 return None, None
90
91 with open(requirements_file_path, "r") as fp:
92 for line in fp.readlines():
93 line = line.strip()
94
95 if line.startswith("#") or not line:
96 continue
97
98 link, req_name = _get_link(line=line)
99
100 if link:
101 links.append(link)
102 else:
103 req_name = line
104
105 reqs.append(req_name)
106
107 return (reqs, links)
108
109
110def apply_vagrant_workaround():

Callers 1

setup.pyFile · 0.90

Calls 1

_get_linkFunction · 0.70

Tested by

no test coverage detected