This repository has been archived by the owner on Jun 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
setup.py
93 lines (72 loc) · 2.72 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import os
from setuptools import find_packages, setup
import versioneer
def resolve_requirements(file):
if not os.path.isfile(file):
file = os.path.join(os.path.dirname(__file__), "requirements", file)
requirements = []
with open(file) as f:
req = f.read().splitlines()
for r in req:
if r.startswith("-r"):
requirements += resolve_requirements(
os.path.join(os.path.dirname(file), r.split(" ")[1]))
else:
requirements.append(r)
return requirements
def read_file(file):
with open(file) as f:
content = f.read()
return content
def unify_requirements(base_requirements: list, *additional_requirement_lists):
for reqs in additional_requirement_lists:
for req in reqs:
if req not in base_requirements:
base_requirements.append(req)
return base_requirements
def parse_all_requirements(backend_requirement_dict: dict):
backend_requirements = {"full": []}
# parse all requirements
for backend_name, requirement_file in backend_requirement_dict.items():
_reqs = resolve_requirements(requirement_file)
backend_requirements[backend_name] = _reqs
# add all requirements to full if not already part of it
backend_requirements["full"] = unify_requirements(
backend_requirements["full"], _reqs)
# for each backend: check if requirement is already in base requirements
for backend_name, reqs in backend_requirements.items():
if backend_name == "base":
continue
for _req in reqs:
if _req in backend_requirements["base"]:
reqs.pop(reqs.index(_req))
backend_requirements[backend_name] = reqs
return backend_requirements
requirement_files = {
"base": "base.txt",
"sklearn": "base.txt", # no extra requirements necessary
"torch": "torch.txt",
"torchscript": "torch.txt",
"tensorflow": "tensorflow.txt",
"tensorflow_eager": "tensorflow.txt",
"chainer": "chainer.txt"
}
requirement_dict = parse_all_requirements(requirement_files)
readme = read_file(os.path.join(os.path.dirname(__file__), "README.md"))
setup(
name='delira',
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
packages=find_packages(),
url='https://github.com/delira-dev/delira/',
test_suite="unittest",
long_description=readme,
long_description_content_type='text/markdown',
maintainer="Justus Schock",
maintainer_email="[email protected]",
license='BSD-2',
install_requires=requirement_dict.pop("base"),
tests_require=["coverage"],
python_requires=">=3.5",
extras_require=requirement_dict
)