-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
17 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,105 +15,34 @@ | |
# ============================================================================== | ||
import setuptools | ||
from pathlib import Path | ||
from distutils.core import setup | ||
from setuptools import setup | ||
import re | ||
|
||
|
||
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!", "!" | ||
long_description = (this_directory / "README.rst").read_text(encoding="utf-8") | ||
long_description = re.sub( | ||
r"<img [^>]*class=\"only-dark\"[^>]*>", | ||
"", | ||
long_description, | ||
flags=re.MULTILINE, | ||
) | ||
|
||
long_description = re.sub( | ||
r"<a [^>]*class=\"only-dark\"[^>]*>((?:(?!<\/a>).)|\s)*<\/a>\n", | ||
"", | ||
long_description, | ||
flags=re.MULTILINE, | ||
) | ||
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-models", | ||
version="1.1.9", | ||
version="1.1.10", | ||
author="ivy", | ||
author_email="[email protected]", | ||
description=( | ||
|