Skip to content

Commit 7053dd2

Browse files
committed
refactor: remove redundant references to binaries
1 parent 16cc055 commit 7053dd2

File tree

6 files changed

+7
-342
lines changed

6 files changed

+7
-342
lines changed

MANIFEST.in

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
11
include requirements/requirements.txt
2-
include ivy/compiler/utils/*.so
3-
include ivy/compiler/utils/*.pyd
4-
include ivy/compiler/*.so
5-
include ivy/compiler/*.pyd
6-
include ivy/compiler/*.py
7-
include binaries.json
8-
include available_configs.json

available_configs.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

binaries.json

Lines changed: 0 additions & 161 deletions
This file was deleted.

ivy/transpiler/exceptions/exceptions.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ def __init__(self, *messages, include_backend=False, propagate=False):
3636
super().__init__(*messages, include_backend=include_backend, propagate=propagate)
3737

3838

39-
class ExpiredBinariesException(SourceToSourceTranslatorException):
40-
def __init__(self, *messages, include_backend=False, propagate=False):
41-
super().__init__(*messages, include_backend=include_backend, propagate=propagate)
42-
43-
4439
def format_missing_frontends_msg(frequency):
4540
"""Format the missing frontends warning message."""
4641
missing_functions = "\n-> ".join(

ivy/utils/binaries.py

Lines changed: 5 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,8 @@
1-
import os
2-
import logging
3-
import json
4-
from packaging import tags
5-
from urllib import request
6-
from tqdm import tqdm
7-
8-
9-
def _get_paths_from_binaries(binaries, root_dir=""):
10-
"""Get all the paths from the binaries.json into a list."""
11-
paths = []
12-
ext = "pyd" if os.name == "nt" else "so"
13-
if isinstance(binaries, str):
14-
return [os.path.join(root_dir, binaries + "." + ext)]
15-
elif isinstance(binaries, dict):
16-
for k, v in binaries.items():
17-
paths += _get_paths_from_binaries(v, os.path.join(root_dir, k))
18-
else:
19-
for i in binaries:
20-
paths += _get_paths_from_binaries(i, root_dir)
21-
return paths
1+
import warnings
222

233

244
def cleanup_and_fetch_binaries(clean=True):
25-
folder_path = os.sep.join(__file__.split(os.sep)[:-3])
26-
binaries_path = os.path.join(folder_path, "binaries.json")
27-
available_configs_path = os.path.join(folder_path, "available_configs.json")
28-
if os.path.exists(binaries_path):
29-
binaries_dict = json.load(open(binaries_path))
30-
available_configs = json.load(open(available_configs_path))
31-
binaries_paths = _get_paths_from_binaries(binaries_dict, folder_path)
32-
binaries_exts = {path.split(".")[-1] for path in binaries_paths}
33-
34-
# clean up existing binaries
35-
if clean:
36-
print("Cleaning up existing binaries...", end="\r")
37-
for root, _, files in os.walk(folder_path, topdown=True):
38-
for file in files:
39-
if file.split(".")[-1] in binaries_exts:
40-
os.remove(os.path.join(root, file))
41-
print("Cleaning up existing binaries --> done")
42-
43-
print("Downloading new binaries...")
44-
all_tags = list(tags.sys_tags())
45-
46-
version = os.environ["VERSION"] if "VERSION" in os.environ else "main"
47-
terminate = False
48-
49-
# download binaries for the tag with highest precedence
50-
with tqdm(total=len(binaries_paths)) as pbar:
51-
for tag in all_tags:
52-
if terminate:
53-
break
54-
for path in binaries_paths:
55-
module = path[len(folder_path) :][1:].split(os.sep)[1]
56-
if (
57-
os.path.exists(path)
58-
or str(tag) not in available_configs[module]
59-
):
60-
continue
61-
folders = path.split(os.sep)
62-
_, file_path = os.sep.join(folders[:-1]), folders[-1]
63-
ext = "pyd" if os.name == "nt" else "so"
64-
file_name = f"{file_path[:-(len(ext)+1)]}_{tag}.{ext}"
65-
search_path = f"{module}/{file_name}"
66-
try:
67-
response = request.urlopen(
68-
"https://github.com/ivy-llc/binaries/raw/"
69-
f"{version}/{search_path}",
70-
timeout=40,
71-
)
72-
os.makedirs(os.path.dirname(path), exist_ok=True)
73-
with open(path, "wb") as f:
74-
f.write(response.read())
75-
terminate = path == binaries_paths[-1]
76-
pbar.update(1)
77-
except request.HTTPError:
78-
break
79-
if terminate:
80-
print("Downloaded all binaries!")
81-
else:
82-
print(
83-
"Couldn't download all binaries. Try importing ivy to get more "
84-
"details about the missing binaries."
85-
)
5+
warnings.warn(
6+
"The Ivy binaries are no longer used - there is no need to fetch them",
7+
DeprecationWarning,
8+
)

setup.py

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -15,80 +15,16 @@
1515
# ==============================================================================
1616
__version__ = None
1717

18-
import setuptools
19-
from setuptools import setup
2018
from pathlib import Path
21-
from urllib import request
22-
import os
23-
import json
2419
import re
25-
26-
27-
def _get_paths_from_binaries(binaries, root_dir=""):
28-
"""Get all the paths from the binaries.json into a list."""
29-
paths = []
30-
ext = "pyd" if os.name == "nt" else "so"
31-
if isinstance(binaries, str):
32-
return [os.path.join(root_dir, binaries + "." + ext)]
33-
elif isinstance(binaries, dict):
34-
for k, v in binaries.items():
35-
paths += _get_paths_from_binaries(v, os.path.join(root_dir, k))
36-
else:
37-
for i in binaries:
38-
paths += _get_paths_from_binaries(i, root_dir)
39-
return paths
20+
import setuptools
21+
from setuptools import setup
4022

4123

4224
def _strip(line):
4325
return line.split(" ")[0].split("#")[0].split(",")[0]
4426

4527

46-
# Download all relevant binaries in binaries.json
47-
binaries_dict = json.load(open("binaries.json"))
48-
available_configs = json.load(open("available_configs.json"))
49-
binaries_paths = _get_paths_from_binaries(binaries_dict)
50-
version = os.environ.get("VERSION", "main")
51-
fixed_tag = os.environ.get("TAG", None)
52-
clean = os.environ.get("CLEAN", None)
53-
terminate = False
54-
all_tags, python_tag, plat_name, options = None, None, None, None
55-
if fixed_tag:
56-
python_tag, _, plat_name = str(fixed_tag).split("-")
57-
options = {"bdist_wheel": {"python_tag": python_tag, "plat_name": plat_name}}
58-
all_tags = [fixed_tag]
59-
else:
60-
from pip._vendor.packaging import tags
61-
62-
all_tags = list(tags.sys_tags())
63-
64-
# download binaries for the tag with highest precedence
65-
for tag in all_tags:
66-
if terminate:
67-
break
68-
for path in binaries_paths:
69-
module = path.split(os.sep)[1]
70-
if (os.path.exists(path) and not clean) or str(tag) not in available_configs[
71-
module
72-
]:
73-
continue
74-
folders = path.split(os.sep)
75-
folder_path, file_path = os.sep.join(folders[:-1]), folders[-1]
76-
ext = "pyd" if os.name == "nt" else "so"
77-
file_name = f"{file_path[:-(len(ext)+1)]}_{tag}.{ext}"
78-
search_path = f"{module}/{file_name}"
79-
try:
80-
response = request.urlopen(
81-
f"https://github.com/ivy-llc/binaries/raw/{version}/{search_path}",
82-
timeout=40,
83-
)
84-
os.makedirs(os.path.dirname(path), exist_ok=True)
85-
with open(path, "wb") as f:
86-
f.write(response.read())
87-
terminate = path == binaries_paths[-1]
88-
except request.HTTPError:
89-
break
90-
91-
9228
this_directory = Path(__file__).parent
9329
long_description = (this_directory / "README.md").read_text(encoding="utf-8")
9430

@@ -135,5 +71,4 @@ def _strip(line):
13571
"License :: OSI Approved :: Apache Software License",
13672
],
13773
license="Apache 2.0",
138-
options=options,
13974
)

0 commit comments

Comments
 (0)