mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 18:09:23 +08:00
默认采用dist 的 whl 安装,没有的情况下才build
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
.eggs/
|
.eggs/
|
||||||
dist/
|
dist/*.gz
|
||||||
|
|
||||||
*.pyc
|
*.pyc
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class GeminiHandler(AsyncAudioVideoStreamHandler):
|
|||||||
# await self.session.send(encode_image(frame))
|
# await self.session.send(encode_image(frame))
|
||||||
# if self.latest_args[2] is not None:
|
# if self.latest_args[2] is not None:
|
||||||
# await self.session.send(encode_image(self.latest_args[2]))
|
# await self.session.send(encode_image(self.latest_args[2]))
|
||||||
print(frame.shape)
|
# print(frame.shape)
|
||||||
newFrame = np.array(frame)
|
newFrame = np.array(frame)
|
||||||
newFrame[0:, :, 0] = 255 - newFrame[0:, :, 0]
|
newFrame[0:, :, 0] = 255 - newFrame[0:, :, 0]
|
||||||
self.video_queue.put_nowait(newFrame)
|
self.video_queue.put_nowait(newFrame)
|
||||||
|
|||||||
BIN
dist/gradio_webrtc-0.0.30.dev0-py3-none-any.whl
vendored
Normal file
BIN
dist/gradio_webrtc-0.0.30.dev0-py3-none-any.whl
vendored
Normal file
Binary file not shown.
@@ -2,32 +2,64 @@ import subprocess
|
|||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import shutil
|
import shutil
|
||||||
|
import argparse
|
||||||
|
|
||||||
# 获取当前脚本所在的目录
|
def check_node_installed():
|
||||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
try:
|
||||||
|
# 尝试运行 `node -v` 命令
|
||||||
|
subprocess.check_output(['node', '-v'])
|
||||||
|
print("Node.js is installed.")
|
||||||
|
return True
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print("Node.js is not installed or not found in PATH.")
|
||||||
|
return False
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("Node.js is not installed or not found in PATH.")
|
||||||
|
return False
|
||||||
|
|
||||||
# 切换到当前脚本所在的目录
|
def install_wheel(whl_file, force_reinstall=False):
|
||||||
os.chdir(script_dir)
|
if force_reinstall:
|
||||||
|
subprocess.run(['pip', 'install', '--force-reinstall', whl_file])
|
||||||
|
print(f"Force reinstallation of {whl_file} successful.")
|
||||||
|
else:
|
||||||
|
subprocess.run(['pip', 'install', whl_file])
|
||||||
|
print(f"Installation of {whl_file} successful.")
|
||||||
|
|
||||||
# 移除 gradio_webrtc 包
|
def main(force_reinstall):
|
||||||
subprocess.run(['pip', 'uninstall', '-y', 'gradio_webrtc'])
|
# 获取当前脚本所在的目录
|
||||||
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
# 删除已有的 dist 目录
|
# 切换到当前脚本所在的目录
|
||||||
if os.path.exists('dist'):
|
os.chdir(script_dir)
|
||||||
shutil.rmtree('dist')
|
|
||||||
|
|
||||||
# 执行 gradio cc install
|
# 查找 dist 目录下的 .whl 文件
|
||||||
subprocess.run(['gradio', 'cc', 'install'])
|
whl_files = glob.glob('dist/*.whl')
|
||||||
|
|
||||||
# 执行 gradio cc build --no-generate-docs
|
if not check_node_installed() or whl_files is None or len(whl_files) == 0:
|
||||||
subprocess.run(['gradio', 'cc', 'build', '--no-generate-docs'])
|
# 移除 gradio_webrtc 包
|
||||||
|
subprocess.run(['pip', 'uninstall', '-y', 'gradio_webrtc'])
|
||||||
|
|
||||||
# 查找 dist 目录下的 .whl 文件
|
# 删除已有的 dist 目录
|
||||||
whl_files = glob.glob('dist/*.whl')
|
if os.path.exists('dist'):
|
||||||
|
shutil.rmtree('dist')
|
||||||
|
|
||||||
if whl_files:
|
# 执行 gradio cc install
|
||||||
whl_file = whl_files[0]
|
subprocess.run(['gradio', 'cc', 'install'])
|
||||||
# 安装 .whl 文件
|
|
||||||
subprocess.run(['pip', 'install', whl_file])
|
# 执行 gradio cc build --no-generate-docs
|
||||||
else:
|
subprocess.run(['gradio', 'cc', 'build', '--no-generate-docs'])
|
||||||
print("没有找到 .whl 文件")
|
|
||||||
|
if whl_files:
|
||||||
|
whl_file = whl_files[0]
|
||||||
|
# 安装 .whl 文件
|
||||||
|
install_wheel(whl_file, force_reinstall)
|
||||||
|
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)
|
||||||
Reference in New Issue
Block a user