mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-04 17:39:23 +08:00
优化更新脚本的处理逻辑
This commit is contained in:
@@ -25,7 +25,7 @@ def install_wheel(whl_file, force_reinstall=True):
|
||||
subprocess.run(['pip', 'install', whl_file])
|
||||
print(f"Installation of {whl_file} successful.")
|
||||
|
||||
def main(force_reinstall):
|
||||
def main():
|
||||
# 获取当前脚本所在的目录
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
@@ -35,7 +35,11 @@ def main(force_reinstall):
|
||||
# 查找 dist 目录下的 .whl 文件
|
||||
whl_files = glob.glob('dist/*.whl')
|
||||
|
||||
if not check_node_installed() or whl_files is None or len(whl_files) == 0:
|
||||
# 有node 且没有whl文件时,执行gradio cc install和gradio cc build
|
||||
if (whl_files is None or len(whl_files)) == 0:
|
||||
if not check_node_installed():
|
||||
print ("need to build .whl, but nodejs not installed")
|
||||
return
|
||||
# 移除 gradio_webrtc 包
|
||||
subprocess.run(['pip', 'uninstall', '-y', 'gradio_webrtc'])
|
||||
|
||||
@@ -49,17 +53,18 @@ def main(force_reinstall):
|
||||
# 执行 gradio cc build --no-generate-docs
|
||||
subprocess.run(['gradio', 'cc', 'build', '--no-generate-docs'])
|
||||
|
||||
# 查找 dist 目录下的 .whl 文件
|
||||
whl_files = glob.glob('dist/*.whl')
|
||||
if whl_files:
|
||||
whl_file = whl_files[0]
|
||||
# 安装 .whl 文件
|
||||
install_wheel(whl_file, force_reinstall)
|
||||
install_wheel(whl_file, True)
|
||||
else:
|
||||
print("没有找到 .whl 文件")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 解析命令行参数
|
||||
parser = argparse.ArgumentParser(description="Update and install gradio-webrtc package.")
|
||||
parser.add_argument('--force-reinstall', action='store_true', help='Force reinstall the .whl file')
|
||||
args = parser.parse_args()
|
||||
|
||||
main(args.force_reinstall)
|
||||
main()
|
||||
Reference in New Issue
Block a user