homebrew-core/Formula/openimageio.rb

86 lines
2.6 KiB
Ruby

class Openimageio < Formula
desc "Library for reading, processing and writing images"
homepage "https://openimageio.org/"
url "https://github.com/OpenImageIO/oiio/archive/Release-2.2.12.0.tar.gz"
sha256 "6010b0642b5bf9c045c397a0f0a7efec232fdaffb49984d449073d006e9004a6"
license "BSD-3-Clause"
head "https://github.com/OpenImageIO/oiio.git"
livecheck do
url :stable
strategy :github_latest
regex(%r{href=.*?/tag/(?:Release[._-])?v?(\d+(?:\.\d+)+)["' >]}i)
end
bottle do
sha256 big_sur: "3df83ab1ae7839a94676222239912f28cc4192ba977fe44acebd07c20b678f76"
sha256 catalina: "8c040bf300de4c716578d20cd0cab302ede08588761fa1f56e45ca98d245cbab"
sha256 mojave: "940b43b047c56509bb52fe39912ac9cf3cfec63525e706a9f1ff0df79c15c48f"
end
depends_on "cmake" => :build
depends_on "pkg-config" => :build
depends_on "boost"
depends_on "boost-python3"
depends_on "ffmpeg"
depends_on "freetype"
depends_on "giflib"
depends_on "ilmbase"
depends_on "jpeg"
depends_on "libheif"
depends_on "libpng"
depends_on "libraw"
depends_on "libtiff"
depends_on "opencolorio"
depends_on "openexr"
depends_on "pybind11"
depends_on "python@3.9"
depends_on "webp"
def install
args = std_cmake_args + %w[
-DCCACHE_FOUND=
-DEMBEDPLUGINS=ON
-DUSE_FIELD3D=OFF
-DUSE_JPEGTURBO=OFF
-DUSE_NUKE=OFF
-DUSE_OPENCV=OFF
-DUSE_OPENGL=OFF
-DUSE_OPENJPEG=OFF
-DUSE_PTEX=OFF
-DUSE_QT=OFF
]
# CMake picks up the system's python dylib, even if we have a brewed one.
py3ver = Language::Python.major_minor_version Formula["python@3.9"].opt_bin/"python3"
py3prefix = Formula["python@3.9"].opt_frameworks/"Python.framework/Versions/#{py3ver}"
on_linux do
py3prefix = Formula["python@3.9"].opt_prefix
end
ENV["PYTHONPATH"] = lib/"python#{py3ver}/site-packages"
args << "-DPYTHON_EXECUTABLE=#{py3prefix}/bin/python3"
args << "-DPYTHON_LIBRARY=#{py3prefix}/lib/#{shared_library("libpython#{py3ver}")}"
args << "-DPYTHON_INCLUDE_DIR=#{py3prefix}/include/python#{py3ver}"
mkdir "build" do
system "cmake", "..", *args
system "make", "install"
end
end
test do
test_image = test_fixtures("test.jpg")
assert_match "#{test_image} : 1 x 1, 3 channel, uint8 jpeg",
shell_output("#{bin}/oiiotool --info #{test_image} 2>&1")
output = <<~EOS
from __future__ import print_function
import OpenImageIO
print(OpenImageIO.VERSION_STRING)
EOS
assert_match version.major_minor_patch.to_s, pipe_output(Formula["python@3.9"].opt_bin/"python3", output, 0)
end
end