-
-
Notifications
You must be signed in to change notification settings - Fork 136
/
setup.py
51 lines (40 loc) · 1.39 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""The setup script."""
from pathlib import Path
from setuptools import setup
def parse_reqs(filepath: str) -> list:
"""
Parse a file path containing requirements and return a list of requirements.
Will properly follow ``-r`` and ``--requirements`` links like ``pip``. This
means nested requirements will be returned as one list.
Other ``pip``-specific lines are excluded.
Args:
filepath: The path to the requirements file
Returns:
All the requirements as a list.
"""
path = Path(filepath)
reqstr = path.read_text()
reqs = []
for line in reqstr.splitlines():
line = line.strip()
if line == "":
continue
elif not line or line.startswith("#"):
# comments are lines that start with # only
continue
elif line.startswith("-r") or line.startswith("--requirement"):
_, new_filename = line.split()
new_file_path = path.parent / new_filename
reqs.extend(parse_reqs(new_file_path))
elif line.startswith("-f") or line.startswith("-i") or line.startswith("--"):
continue
elif line.startswith("-Z") or line.startswith("--always-unzip"):
continue
else:
reqs.append(line)
return reqs
requirements = parse_reqs("requirements.txt")
setup(
install_requires=requirements,
py_modules=[],
)