-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
137 lines (118 loc) · 4.29 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# lint as: python3
# Copyright 2021 The Ivy Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License..
# ==============================================================================
import setuptools
from pathlib import Path
from distutils.core import setup
def _strip(line):
return line.split(" ")[0].split("#")[0].split(",")[0]
def _replace_logos_html(txt):
# html-containing chunks
chunks = txt.split(".. raw:: html")
# backend logos
backends_chunk = chunks[2]
bc = backends_chunk.split("\n\n")
img_str = (
".. image:: https://github.com/unifyai/unifyai.github.io/blob/main/img/externally_linked/logos/supported/frameworks.png?raw=true\n" # noqa
" :width: 100%"
)
backends_chunk = "\n\n".join(bc[0:1] + [img_str] + bc[2:])
# library logos
libraries_chunk = chunks[3]
lc = libraries_chunk.split("\n\n")
img_str = (
".. image:: https://github.com/unifyai/unifyai.github.io/blob/main/img/externally_linked/ivy_libraries.png?raw=true\n" # noqa
" :width: 100%"
)
libraries_chunk = "\n\n".join(lc[0:1] + [img_str] + lc[2:])
# re-join
chunks[3] = libraries_chunk
return "".join(
[
".. raw:: html".join(chunks[0:2]),
backends_chunk,
".. raw:: html".join(chunks[3:]),
]
)
def _replace_gif(gif_chunk):
png_url = "https://{}.png".format(
gif_chunk.split(".gif?raw=true'>")[0].split("https://")[-1]
)
gc = gif_chunk.split("\n\n")
img_str = ".. image:: {}?raw=true\n" " :width: 100%".format(png_url)
return "\n\n".join(gc[0:1] + [img_str] + gc[2:])
def _replace_gifs_html(txt):
# html-containing chunks
chunks = txt.split(".. raw:: html")
# go through each chunk, replacing all html gifs with rst images
return_str = ""
for i, chunk in enumerate(chunks):
new_chunk = chunk
delimiter = ".. raw:: html"
if ".gif?raw=true'>" in chunk:
new_chunk = _replace_gif(chunk)
delimiter = ""
if i == 0:
return_str = chunk
else:
return_str = delimiter.join([return_str, new_chunk])
return return_str
def _is_html(line):
line_squashed = line.replace(" ", "")
if not line_squashed:
return False
if line_squashed[0] == "<" and line_squashed[-1] == ">":
return True
return False
def _is_raw_block(line):
line_squashed = line.replace(" ", "")
if len(line_squashed) < 11:
return False
if line_squashed[-11:] == "..raw::html":
return True
return False
this_directory = Path(__file__).parent
text = (this_directory / "README.rst").read_text()
text = _replace_logos_html(text).replace(
". Click on the icons below to learn more!", "!"
)
text = _replace_gifs_html(text)
lines = text.split("\n")
lines = [line for line in lines if not (_is_html(line) or _is_raw_block(line))]
long_description = "\n".join(lines)
setup(
name="ivy-builder",
version="0.0.1.post0",
author="Unify",
author_email="hello@unify.ai",
description="Build custom Ivy training tasks with clear, hierarchical and robust user specifications.\n", # noqa
long_description_content_type="text/x-rst",
long_description=long_description,
url="https://unify.ai/docs/builder",
project_urls={
"Docs": "https://unify.ai/docs/builder/",
"Source": "https://github.com/unifyai/builder",
},
packages=setuptools.find_packages(),
install_requires=[_strip(line) for line in open("requirements.txt", "r")],
scripts=[
"scripts/print_json_args.py",
"scripts/remove_checkpoints.py",
"scripts/reset_to_defaults.sh",
"scripts/format_dataset_containers.py",
],
classifiers=["License :: OSI Approved :: Apache Software License"],
license="Apache 2.0",
)