server: cleanup old dependencies on runtime version change

This commit is contained in:
Koushik Dutta
2022-12-11 12:51:08 -08:00
parent ef36898adc
commit 2294d2f22d
4 changed files with 66 additions and 40 deletions

View File

@@ -4,7 +4,7 @@ import asyncio
import base64
import gc
import json
import mimetypes
import sys
import os
import platform
import shutil
@@ -274,14 +274,15 @@ class PluginRemote:
zip = zipfile.ZipFile(zipPath)
plugin_volume = os.environ.get('SCRYPTED_PLUGIN_VOLUME')
python_prefix = os.path.join(plugin_volume, 'python-%s-%s' % (platform.system(), platform.machine()))
if not os.path.exists(python_prefix):
os.makedirs(python_prefix)
python_version = 'python%s' % str(
sys.version_info[0])+"."+str(sys.version_info[1])
print('python version:', python_version)
python_prefix = os.path.join(plugin_volume, 'python%s-%s-%s' % (python_version, platform.system(), platform.machine()))
if not os.path.exists(python_prefix):
os.makedirs(python_prefix)
if 'requirements.txt' in zip.namelist():
requirements = zip.open('requirements.txt').read()
str_requirements = requirements.decode('utf8')