Skip to content

Commit 98947d1

Browse files
committed
run installers for newly installed extensions
1 parent a1a3763 commit 98947d1

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

launch.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,26 @@ def version_check(commit):
105105
print("version check failed", e)
106106

107107

108+
def run_extension_installer(extension_dir):
109+
path_installer = os.path.join(extension_dir, "install.py")
110+
if not os.path.isfile(path_installer):
111+
return
112+
113+
try:
114+
env = os.environ.copy()
115+
env['PYTHONPATH'] = os.path.abspath(".")
116+
117+
print(run(f'"{python}" "{path_installer}"', errdesc=f"Error running install.py for extension {extension_dir}", custom_env=env))
118+
except Exception as e:
119+
print(e, file=sys.stderr)
120+
121+
108122
def run_extensions_installers():
109123
if not os.path.isdir(dir_extensions):
110124
return
111125

112126
for dirname_extension in os.listdir(dir_extensions):
113-
path_installer = os.path.join(dir_extensions, dirname_extension, "install.py")
114-
if not os.path.isfile(path_installer):
115-
continue
116-
117-
try:
118-
env = os.environ.copy()
119-
env['PYTHONPATH'] = os.path.abspath(".")
120-
121-
print(run(f'"{python}" "{path_installer}"', errdesc=f"Error running install.py for extension {dirname_extension}", custom_env=env))
122-
except Exception as e:
123-
print(e, file=sys.stderr)
127+
run_extension_installer(os.path.join(dir_extensions, dirname_extension))
124128

125129

126130
def prepare_enviroment():

modules/ui_extensions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ def install_extension_from_url(dirname, url):
134134

135135
os.rename(tmpdir, target_dir)
136136

137+
import launch
138+
launch.run_extension_installer(target_dir)
139+
137140
extensions.list_extensions()
138141
return [extension_table(), html.escape(f"Installed into {target_dir}. Use Installed tab to restart.")]
139142
finally:

0 commit comments

Comments
 (0)