Skip to content
This repository was archived by the owner on Apr 26, 2026. It is now read-only.

Commit 3392608

Browse files
authored
Update install.py
1 parent 64a9abc commit 3392608

1 file changed

Lines changed: 40 additions & 28 deletions

File tree

src/install.py

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,30 @@
1616
_installing = set()
1717

1818
def main(package, noconfirm=False):
19+
local = False
20+
# check if package is local
21+
if package.endswith(".car"):
22+
os.system(f"unzip {package}")
23+
os.chdir(package)
24+
with open("install_script.py", "r") as f:
25+
script = f.read()
26+
local = True
1927
# first check if the name is correct, autocorrect if not
2028
# using umbrella/autocorrect_package.py (unlicense)
21-
autocorrected = Autocorrect.main(package)
22-
if autocorrected != package:
23-
package = autocorrected
29+
if not local:
30+
autocorrected = Autocorrect.main(package)
31+
if autocorrected != package:
32+
package = autocorrected
2433

2534
# Prevent circular dependencies and infinite loops
2635
if package in _installing:
2736
return
2837
_installing.add(package)
2938
try:
3039
# save time fetching scripts, check if the package is in lists quickly
31-
if get_package_list.main(package) != True:
32-
return False
40+
if not local:
41+
if get_package_list.main(package) != True:
42+
return False
3343

3444
# main
3545
try:
@@ -62,35 +72,36 @@ def write_installed_versions(path, versions):
6272
f.write("\n".join(lines) + "\n")
6373

6474
# go to /tmp
65-
os.chdir("/tmp/")
75+
if not local:
76+
os.chdir("/tmp/")
77+
78+
status("Fetching package")
6679

67-
status("Fetching package")
80+
# fetch all repos for the install script
81+
found = False
6882

69-
# fetch all repos for the install script
70-
found = False
83+
for mirror in mirrors.install_script_places:
84+
url = f"{mirror.rstrip('/')}/{package}/install_script"
7185

72-
for mirror in mirrors.install_script_places:
73-
url = f"{mirror.rstrip('/')}/{package}/install_script"
86+
result = os.system(f"curl -s -L -o install_script.py {url}")
7487

75-
result = os.system(f"curl -s -L -o install_script.py {url}")
88+
with open("install_script.py", "r") as f:
89+
script = f.read()
7690

77-
with open("install_script.py", "r") as f:
78-
script = f.read()
79-
80-
# github returns 404: Not Found in case the file does not exist,
81-
# so handle that case too
82-
if script != "404: Not Found":
83-
found = True
84-
break
85-
else:
86-
pass
91+
# github returns 404: Not Found in case the file does not exist,
92+
# so handle that case too
93+
if script != "404: Not Found":
94+
found = True
95+
break
96+
else:
97+
pass
8798

88-
if not found:
89-
status("Failed to fetch install script from all mirrors", "error")
90-
exit(1)
99+
if not found:
100+
status("Failed to fetch install script from all mirrors", "error")
101+
exit(1)
91102

92103
# import the script as a python library
93-
spec = importlib.util.spec_from_file_location("install_script", "/tmp/install_script.py")
104+
spec = importlib.util.spec_from_file_location("install_script", "install_script.py")
94105
install_script = importlib.util.module_from_spec(spec)
95106
spec.loader.exec_module(install_script)
96107

@@ -127,8 +138,9 @@ def write_installed_versions(path, versions):
127138
if not noconfirm:
128139
status("The following packages are going to be installed:")
129140
print(" ", end="")
130-
for i in install_script.car_deps:
131-
print(i, end=", ")
141+
if "car_deps" in script:
142+
for i in install_script.car_deps:
143+
print(i, end=", ")
132144
print(package) # appending to the list did not work for some reason
133145
console.print("::", style="blue bold", end=" ")
134146
sure = input("Install dependencies and build? (Y/n) ")

0 commit comments

Comments
 (0)