Merge pull request #1240 from pypeclub/1175-add-ffmpeg-and-othe-binaries-to-build

Pype 3: Handle binary dependencies
This commit is contained in:
Milan Kolar 2021-04-16 10:07:03 +02:00 committed by GitHub
commit 6a84f45635
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 491 additions and 117 deletions

View file

@ -43,6 +43,13 @@ from .anatomy import (
from .config import get_datetime_data
from .vendor_bin_utils import (
get_vendor_bin_path,
get_oiio_tools_path,
get_ffmpeg_tool_path,
ffprobe_streams
)
from .python_module_tools import (
modules_from_path,
recursive_bases_from_class,
@ -120,11 +127,6 @@ from .path_tools import (
get_last_version_from_path
)
from .ffmpeg_utils import (
get_ffmpeg_tool_path,
ffprobe_streams
)
from .editorial import (
is_overlapping_otio_ranges,
otio_range_to_frame_range,
@ -147,6 +149,11 @@ __all__ = [
"get_paths_from_environ",
"get_global_environments",
"get_vendor_bin_path",
"get_oiio_tools_path",
"get_ffmpeg_tool_path",
"ffprobe_streams",
"modules_from_path",
"recursive_bases_from_class",
"classes_from_module",
@ -203,9 +210,6 @@ __all__ = [
"get_version_from_path",
"get_last_version_from_path",
"ffprobe_streams",
"get_ffmpeg_tool_path",
"terminal",
"merge_dict",

View file

@ -9,6 +9,7 @@ import tempfile
from .execute import run_subprocess
from .profiles_filtering import filter_profiles
from .vendor_bin_utils import get_oiio_tools_path
from openpype.settings import get_project_settings
@ -235,7 +236,7 @@ def oiio_supported():
Returns:
(bool)
"""
oiio_path = os.getenv("OPENPYPE_OIIO_PATH", "")
oiio_path = get_oiio_tools_path()
if not oiio_path or not os.path.exists(oiio_path):
log.debug("OIIOTool is not configured or not present at {}".
format(oiio_path))
@ -269,7 +270,7 @@ def decompress(target_dir, file_url,
(int(input_frame_end) > int(input_frame_start))
oiio_cmd = []
oiio_cmd.append(os.getenv("OPENPYPE_OIIO_PATH"))
oiio_cmd.append(get_oiio_tools_path())
oiio_cmd.append("--compression none")
@ -328,7 +329,7 @@ def should_decompress(file_url):
"""
if oiio_supported():
output = run_subprocess([
os.getenv("OPENPYPE_OIIO_PATH"),
get_oiio_tools_path(),
"--info", "-v", file_url])
return "compression: \"dwaa\"" in output or \
"compression: \"dwab\"" in output

View file

@ -1,33 +1,60 @@
import os
import logging
import json
import platform
import subprocess
from . import get_paths_from_environ
log = logging.getLogger("FFmpeg utils")
def get_ffmpeg_tool_path(tool="ffmpeg"):
"""Find path to ffmpeg tool in FFMPEG_PATH paths.
def get_vendor_bin_path(bin_app):
"""Path to OpenPype vendorized binaries.
Function looks for tool in paths set in FFMPEG_PATH environment. If tool
exists then returns it's full path.
Vendorized executables are expected in specific hierarchy inside build or
in code source.
"{OPENPYPE_ROOT}/vendor/bin/{name of vendorized app}/{platform}"
Args:
tool (string): tool name
bin_app (str): Name of vendorized application.
Returns:
(str): tool name itself when tool path was not found. (FFmpeg path
may be set in PATH environment variable)
str: Path to vendorized binaries folder.
"""
dir_paths = get_paths_from_environ("FFMPEG_PATH")
for dir_path in dir_paths:
for file_name in os.listdir(dir_path):
base, _ext = os.path.splitext(file_name)
if base.lower() == tool.lower():
return os.path.join(dir_path, tool)
return tool
return os.path.join(
os.environ["OPENPYPE_ROOT"],
"vendor",
"bin",
bin_app,
platform.system().lower()
)
def get_oiio_tools_path(tool="oiiotool"):
"""Path to vendorized OpenImageIO tool executables.
Args:
tool (string): Tool name (oiiotool, maketx, ...).
Default is "oiiotool".
"""
oiio_dir = get_vendor_bin_path("oiio")
return os.path.join(oiio_dir, tool)
def get_ffmpeg_tool_path(tool="ffmpeg"):
"""Path to vendorized FFmpeg executable.
Args:
tool (string): Tool name (ffmpeg, ffprobe, ...).
Default is "ffmpeg".
Returns:
str: Full path to ffmpeg executable.
"""
ffmpeg_dir = get_vendor_bin_path("ffmpeg")
if platform.system().lower() == "windows":
ffmpeg_dir = os.path.join(ffmpeg_dir, "bin")
return os.path.join(ffmpeg_dir, tool)
def ffprobe_streams(path_to_file, logger=None):

View file

@ -45,7 +45,7 @@ class ExtractScanlineExr(pyblish.api.InstancePlugin):
stagingdir = os.path.normpath(repre.get("stagingDir"))
oiio_tool_path = os.getenv("OPENPYPE_OIIO_PATH", "")
oiio_tool_path = openpype.lib.get_oiio_tools_path()
if not os.path.exists(oiio_tool_path):
self.log.error(
"OIIO tool not found in {}".format(oiio_tool_path))

View file

@ -2,15 +2,9 @@
"studio_name": "Studio name",
"studio_code": "stu",
"environment": {
"FFMPEG_PATH": {
"windows": "{OPENPYPE_REPOS_ROOT}/vendor/bin/ffmpeg_exec/windows/bin",
"darwin": "{OPENPYPE_REPOS_ROOT}/vendor/bin/ffmpeg_exec/darwin/bin",
"linux": ":{OPENPYPE_REPOS_ROOT}/vendor/bin/ffmpeg_exec/linux"
},
"OPENPYPE_OCIO_CONFIG": "{STUDIO_SOFT}/OpenColorIO-Configs",
"__environment_keys__": {
"global": [
"FFMPEG_PATH",
"OPENPYPE_OCIO_CONFIG"
]
}