mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-24 01:14:22 +01:00
Add option to install plugin dependencies (#3068)
Co-authored-by: Nicholas Tindle <nick@ntindle.com>
This commit is contained in:
27
scripts/install_plugin_deps.py
Normal file
27
scripts/install_plugin_deps.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main():
|
||||
# Plugin packages
|
||||
plugins_dir = Path(os.getenv("PLUGINS_DIR", "plugins"))
|
||||
for plugin in plugins_dir.glob("*.zip"):
|
||||
with zipfile.ZipFile(str(plugin), "r") as zfile:
|
||||
try:
|
||||
basedir = zfile.namelist()[0]
|
||||
basereqs = os.path.join(basedir, "requirements.txt")
|
||||
extracted = zfile.extract(basereqs, path=plugins_dir)
|
||||
subprocess.check_call(
|
||||
[sys.executable, "-m", "pip", "install", "-r", extracted]
|
||||
)
|
||||
os.remove(extracted)
|
||||
os.rmdir(os.path.join(plugins_dir, basedir))
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user