server/python-codecs: add support for optional requirements

This commit is contained in:
Koushik Dutta
2024-03-06 11:11:45 -08:00
parent cb7ea1c624
commit c5f33f8eb5
5 changed files with 29 additions and 23 deletions

View File

@@ -5,8 +5,8 @@
// "scrypted.serverRoot": "/server",
// lxc installation
"scrypted.debugHost": "scrypted-server",
"scrypted.serverRoot": "/root/.scrypted",
// "scrypted.debugHost": "scrypted-server",
// "scrypted.serverRoot": "/root/.scrypted",
// windows installation
// "scrypted.debugHost": "koushik-windows",
@@ -17,8 +17,8 @@
// "scrypted.serverRoot": "/home/pi/.scrypted",
// local checkout
// "scrypted.debugHost": "127.0.0.1",
// "scrypted.serverRoot": "/Users/koush/.scrypted",
"scrypted.debugHost": "127.0.0.1",
"scrypted.serverRoot": "/Users/koush/.scrypted",
"scrypted.pythonRemoteRoot": "${config:scrypted.serverRoot}/volume/plugin.zip",
"python.analysis.extraPaths": [

View File

@@ -0,0 +1,6 @@
# gobject instrospection for gstreamer.
PyGObject>=3.30.4; sys_platform != 'win32'
# pyvips is not available on windows, and is preinstalled as part of the installer scripts on
# mac and linux.
pyvips; sys_platform != 'win32'

View File

@@ -1,15 +1,7 @@
# needed by libav to_ndarray
numpy>=1.16.2
# gobject instrospection for gstreamer.
PyGObject>=3.30.4; sys_platform != 'win32'
# libav doesnt work on arm7
av>=10.0.0; sys_platform != 'linux' or platform_machine == 'x86_64' or platform_machine == 'aarch64'
# pyvips is not available on windows, and is preinstalled as part of the installer scripts on
# mac and linux.
pyvips; sys_platform != 'win32'
av>=10.0.0
# in case pyvips fails to load, use a pillow fallback.
# pillow for anything not intel linux, pillow-simd is available on x64 linux

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/server",
"version": "0.94.5",
"version": "0.94.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@scrypted/server",
"version": "0.94.5",
"version": "0.94.6",
"license": "ISC",
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.11",

View File

@@ -41,7 +41,7 @@ import rpc
import rpc_reader
OPTIONAL_REQUIREMENTS = """
SCRYPTED_REQUIREMENTS = """
ptpython
""".strip()
@@ -574,25 +574,33 @@ class PluginRemote:
if not os.path.exists(python_prefix):
os.makedirs(python_prefix)
str_requirements = ""
if 'requirements.txt' in zip.namelist():
str_requirements = zip.open('requirements.txt').read().decode('utf8')
optional_requirements_basename = os.path.join(
python_prefix, 'requirements.optional')
def read_requirements(filename: str) -> str:
if filename in zip.namelist():
return zip.open(filename).read().decode('utf8')
return ''
str_requirements = read_requirements('requirements.txt')
str_optional_requirements = read_requirements('requirements.optional.txt')
scrypted_requirements_basename = os.path.join(
python_prefix, 'requirements.scrypted')
requirements_basename = os.path.join(
python_prefix, 'requirements')
optional_requirements_basename = os.path.join(
python_prefix, 'requirements.optional')
need_pip = True
if str_requirements:
need_pip = need_requirements(requirements_basename, str_requirements)
if not need_pip:
need_pip = need_requirements(optional_requirements_basename, OPTIONAL_REQUIREMENTS)
need_pip = need_requirements(scrypted_requirements_basename, SCRYPTED_REQUIREMENTS)
if need_pip:
remove_pip_dirs(plugin_volume)
install_with_pip(python_prefix, packageJson, OPTIONAL_REQUIREMENTS, optional_requirements_basename, ignore_error=True)
install_with_pip(python_prefix, packageJson, SCRYPTED_REQUIREMENTS, scrypted_requirements_basename, ignore_error=True)
install_with_pip(python_prefix, packageJson, str_requirements, requirements_basename, ignore_error=False)
install_with_pip(python_prefix, packageJson, str_optional_requirements, optional_requirements_basename, ignore_error=True)
else:
print('requirements.txt (up to date)')
print(str_requirements)