File OpenImageIO-3.spec of Package OpenImageIO-3
#
# spec file for package OpenImageIO
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%ifarch aarch64 %{arm}
%bcond_with imageviewer
%else
%bcond_without imageviewer
%endif
%if 0%{?suse_version} > 1500
%bcond_without libheif
%else
%bcond_with libheif
%endif
%bcond_without opencv
%bcond_without python_bindings
%bcond_with apidocs
%bcond_with ptex
%global images_ts 20250119T083517
%global so_ver 3_0
%global major_minor_ver 3.0
%global pkg_name OpenImageIO
%{?primary_python:%define pythons %primary_python}
%{?sle15_python_module_pythons}
%if 0%{?sle_version} < 160000 && 0%{?is_opensuse}
%if 0%{suse_version} < 1600
# requires __has_builtin with keywords
%define gccver 13
%endif
%endif
Name: OpenImageIO-3
Version: 3.0.4.0
Release: 0
Summary: Library for Reading and Writing Images
License: BSD-3-Clause
Group: Productivity/Graphics/Other
URL: https://www.openimageio.org/
Source0: https://github.com/AcademySoftwareFoundation/OpenImageIO/archive/refs/tags/v%{version}.tar.gz#/%{pkg_name}-%{version}.tar.gz
# this contains the actual test images, only used during build
Source1: oiio-images-%{images_ts}.tar.xz
# NOTE: Please don't uncomment a build requirement unless you have submitted the package to factory and it exists
#BuildRequires: Field3D-devel
BuildRequires: cmake >= 3.18.2
BuildRequires: dcmtk-devel
%if %{with apidocs}
BuildRequires: doxygen
%endif
BuildRequires: fdupes
BuildRequires: gcc%{?gccver}-c++
BuildRequires: giflib-devel >= 5.0
BuildRequires: hdf5-devel
# can be dropped when upgrading to 3.x again
BuildRequires: libboost_atomic-devel
BuildRequires: libboost_filesystem-devel
BuildRequires: libboost_system-devel
BuildRequires: libboost_thread-devel
#/ can be dropped when upgrading to 3.x again
BuildRequires: libjpeg-devel
BuildRequires: libpng-devel >= 1.6.0
BuildRequires: openvdb-devel >= 9.0
BuildRequires: pkgconfig
BuildRequires: pugixml-devel
%if %{with python_bindings}
BuildRequires: %{python_module devel >= 3.7}
BuildRequires: %{python_module pybind11-devel >= 2.7}
# required for testsuite
BuildRequires: %{python_module numpy}
%endif
BuildRequires: robin-map-devel >= 1.2.0
BuildRequires: tbb-devel
BuildRequires: txt2man
BuildRequires: pkgconfig(OpenColorIO) >= 2.2
BuildRequires: pkgconfig(OpenEXR) >= 3.1
%if %{with ptex}
BuildRequires: ptex-devel-static
%endif
BuildRequires: pkgconfig(bzip2)
BuildRequires: pkgconfig(fmt)
BuildRequires: pkgconfig(freetype2) >= 2.10
BuildRequires: pkgconfig(libavdevice)
BuildRequires: pkgconfig(libjxl)
%if %{with libheif}
BuildRequires: pkgconfig(libheif) >= 1.11
%endif
BuildRequires: pkgconfig(libopenjp2)
BuildRequires: pkgconfig(libxml-2.0)
%if %{with imageviewer}
BuildRequires: cmake(Qt6Core)
BuildRequires: cmake(Qt6Gui)
BuildRequires: cmake(Qt6OpenGLWidgets)
BuildRequires: cmake(Qt6Widgets)
%endif
BuildRequires: pkgconfig(libraw) >= 0.20
BuildRequires: pkgconfig(libtiff-4) > 4.0
BuildRequires: pkgconfig(libwebp) >= 1.1
BuildRequires: pkgconfig(libwebpdecoder)
BuildRequires: pkgconfig(libwebpdemux)
BuildRequires: pkgconfig(libwebpmux)
%if %{with opencv}
BuildRequires: pkgconfig(opencv4)
%endif
BuildRequires: pkgconfig(zlib)
BuildRequires: fonts-config
Recommends: google-droid-fonts
Conflicts: OpenImageIO
BuildRequires: python-rpm-macros
%description
OpenImageIO is a library for reading and writing images, and a bunch of related
classes, utilities, and applications. There is a particular emphasis on formats
and functionality used in professional, large-scale animation and visual
effects work for film. OpenImageIO is used extensively in animation and VFX
studios all over the world, and is also incorporated into several commercial
products.
%package devel
Summary: Development Files for OpenImageIO
Group: Development/Libraries/C and C++
# Make the cmake finder happy
Requires: OpenImageIO-3 = %{version}
Requires: pkgconfig(Imath)
# /Make the cmake finder happy
Requires: fmt-devel
Requires: libOpenImageIO%{so_ver} = %{version}
Requires: libOpenImageIO_Util%{so_ver} = %{version}
Suggests: %{pkg_name}-devel-doc
Conflicts: OpenImageIO-devel-doc
%description devel
This package provides development libraries and headers needed to build
software using OpenImageIO.
%package devel-doc
Summary: API documentation for OpenImageIO
Group: Productivity/Graphics/Other
Requires: %{pkg_name}-devel
BuildArch: noarch
Conflicts: OpenImageIO-devel-doc
%description devel-doc
This package provides the API documentation for OpenImageIO.
%package -n libOpenImageIO%{so_ver}
Summary: Library for Reading and Writing Images
Group: System/Libraries
# this is unfortunate and a fallout of properly naming the lib after fixing so_ver
Conflicts: libOpenColorIO2_0 = 2.1.1
Conflicts: libOpenColorIO2_0 = 2.1.2
%description -n libOpenImageIO%{so_ver}
OpenImageIO is a library for reading and writing images, and a bunch of related
classes, utilities, and applications. There is a particular emphasis on formats
and functionality used in professional, large-scale animation and visual
effects work for film. OpenImageIO is used extensively in animation and VFX
studios all over the world, and is also incorporated into several commercial
products.
%package -n libOpenImageIO_Util%{so_ver}
Summary: Library for Reading and Writing Images
Group: System/Libraries
%description -n libOpenImageIO_Util%{so_ver}
OpenImageIO is a library for reading and writing images, and a bunch of related
classes, utilities, and applications. There is a particular emphasis on formats
and functionality used in professional, large-scale animation and visual
effects work for film. OpenImageIO is used extensively in animation and VFX
studios all over the world, and is also incorporated into several commercial
products.
%package -n %{python_flavor}-OpenImageIO-3
Summary: Python Bindings for OpenImageIO
Group: Development/Libraries/Python
Conflicts: python3-OpenImageIO
%description -n %{python_flavor}-OpenImageIO-3
This package contains python bindings for OpenImageIO.
%prep
%autosetup -p1 -b 1 -n %{pkg_name}-%{version}
# CMake looks for images at <CMAKE_BINARY_DIR>/testsuite/oiio-images
mkdir -p %{__builddir}/testsuite
ln -sf %{_builddir}/oiio-images-%{images_ts} %{__builddir}/testsuite/oiio-images
# Make sure that bundled libraries are not used
rm -f src/include/pugiconfig.hpp \
src/include/pugixml.hpp
rm -rf src/include/tbb/
find . -iname \*.py -print -exec sed -i '1s@^#!.*@#!%{_bindir}/python3@' '{}' \;
%build
%cmake \
%ifarch ppc
-DNOTHREADS=ON \
%endif
%{?gccver:-DCMAKE_C_COMPILER=gcc-%{gccver} -DCMAKE_CXX_COMPILER=g++-%{gccver}} \
-DCMAKE_CXX_STANDARD=17 \
-DINSTALL_DOCS:BOOL=ON \
-DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir}/%{pkg_name} \
-DCMAKE_INSTALL_MANDIR:PATH=%{_mandir}/man1 \
-DINSTALL_FONTS:BOOL=OFF \
-DLINKSTATIC:BOOL=OFF \
-DUSE_EXTERNAL_PUGIXML:BOOL=ON \
-DUSE_FFMPEG:BOOL=ON \
-DUSE_Nuke:BOOL=OFF \
-DCMAKE_SKIP_RPATH:BOOL=ON \
-DUSE_OPENCV:BOOL=%{?with_opencv:ON}%{!?with_opencv:OFF} \
-DUSE_PYTHON:BOOL=%{?with_python_bindings:ON}%{!?with_python_bindings:OFF} \
-DUSE_Ptex:BOOL=%{?with_ptex:ON}%{!?with_ptex:OFF} \
-DPYTHON_EXECUTABLE:PATH=%{_bindir}/python%{python_version} \
-Dpybind11_DIR=`pybind11-config --cmakedir` \
-DPLUGIN_SEARCH_PATH:PATH=%{_libdir}/%{pkg_name}-%{major_minor_ver} \
..
%cmake_build
%if %{with apidocs}
cd ..
make %{?_smp_mflags} doxygen
%endif
%install
%cmake_install
# Create and own the default plugin directory
mkdir -p %{buildroot}%{_libdir}/%{pkg_name}-%{major_minor_ver}
%if %{with apidocs}
# Install additional devel documentation
cp -a src/doc/doxygen/html/ %{buildroot}%{_docdir}/%{pkg_name}-devel/
%endif
# Clean up licenses installed in _licensedir
rm %{buildroot}%{_docdir}/%{pkg_name}/LICENSE*md
%fdupes -s %{buildroot}
%check
# Make sure testsuite can find required fonts. Especially `DroidSerif.ttf` which is not part of our google-droid-fonts package
# we need
export OPENIMAGEIO_FONTS="$(dirname $(find ${PWD}/src/fonts/ -type f -name \*.ttf) | sort -u | tr '\n' ':' | sed -e 's|:$||g')"
./build/bin/oiiotool --echo "{getattribute(font_dir_list)}"
# without this the python tests can not link the library
export LD_LIBRARY_PATH=%{buildroot}%{_libdir}
# used as suffix for python binary
export PYTHON_VERSION=%{python_version}
export PYTHONPATH=%{buildroot}%{python_sitearch}
export PYTHONDONTWRITEBYTECODE=1
#
# https://github.com/AcademySoftwareFoundation/OpenImageIO/issues/4615
#
# heif -> our libheif does not support h265
# ptex -> fileformat which we do not support
# jpeg-ultrahdr -> fileformat which we do not support
# cmake-consumer docs-examples-cpp -> currently failing tests as they assume normal cmake search paths will work to find the OIIO devel files in the final location
# docs-examples-python -> fails if docs-examples-cpp was not attempted
export disabled_tests="heif|ptex|jpeg-ultrahdr|cmake-consumer|docs-examples-cpp|docs-examples-python"
%ifarch x86_64
%ctest '-E' ${disabled_tests}
%else
# Many test cases are failing on PPC, ARM, ix64 ... ignore for now
%ctest '-E' ${disabled_tests} || true
%endif
%ldconfig_scriptlets -n libOpenImageIO%{so_ver}
%ldconfig_scriptlets -n libOpenImageIO_Util%{so_ver}
%files
%doc %{_docdir}/%{pkg_name}/
%license LICENSE.md
%{_bindir}/*
%{_mandir}/man1/*.1%{ext_man}
%if %{with apidocs}
%files devel-doc
%doc %{_docdir}/%{pkg_name}-devel/
%endif
%files devel
%{_includedir}/%{pkg_name}
%{_libdir}/pkgconfig/OpenImageIO.pc
%{_libdir}/cmake
%{_libdir}/libOpenImageIO.so
%{_libdir}/libOpenImageIO_Util.so
%files -n lib%{pkg_name}%{so_ver}
%license LICENSE.md
%{_libdir}/lib%{pkg_name}.so.*
%dir %{_libdir}/%{pkg_name}-%{major_minor_ver}
%files -n lib%{pkg_name}_Util%{so_ver}
%license LICENSE.md
%{_libdir}/lib%{pkg_name}_Util.so.*
%if %{with python_bindings}
%files -n %{python_flavor}-%{pkg_name}-3
%license LICENSE.md
%dir %{python_sitearch}/%{pkg_name}
%{python_sitearch}/%{pkg_name}/__init__.py
%{python_sitearch}/%{pkg_name}/%{pkg_name}.*.so
%endif
%changelog