Blob Blame History Raw
%global         __cmake_in_source_build 0
%global         libmajor 0
%global         srcname  USD
%bcond_without  alembic
%bcond_with     documentation
%bcond_without  embree
%bcond_without  imaging
# We must keep jemalloc enabled to work around
%bcond_without  jemalloc
%bcond_with     openshading
%bcond_with     openvdb
%bcond_with     ocio
%bcond_with     oiio
%bcond_without  python3
%bcond_with     test

Name:           usd
Version:        21.08
Release:        %autorelease
Summary:        3D VFX pipeline interchange file format

# The entire source is ASL 2.0 except:
# BSD:
#   - pxr/base/gf/ilmbase_*
#   - pxr/base/js/rapidjson/msinttypes/
#   - pxr/base/tf/pxrDoubleConversion/
#   - pxr/base/tf/pxrLZ4/
# MIT:
#   - pxr/imaging/garch/khrplatform.h
#   - pxr/base/js/rapidjson/, except pxr/base/js/rapidjson/msinttypes/
#   - pxr/base/tf/pyLock.cpp (only some sections; most of the file is
#     ASL 2.0)
#   - third_party/renderman-23/plugin/rmanArgsParser/pugixml/
# MIT or Unlicense:
#   - pxr/imaging/hio/stb/
# (Certain build system files are also under licenses other than ASL 2.0, but
# do not contribute their license terms to the built RPMs.)
License:        ASL 2.0 and BSD and MIT and (MIT or Unlicense)

Patch1:         %{srcname}-20.05-soversion.patch

Patch2:         USD-21.08-OpenEXR3.patch

# Base
BuildRequires:  boost-devel
BuildRequires:  boost-program-options
BuildRequires:  cmake
BuildRequires:  dos2unix
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig(blosc)
BuildRequires:  pkgconfig(tbb)

# Documentation
%if %{with documentation}
BuildRequires:  doxygen
BuildRequires:  graphviz

# For imaging and usd imaging
%if %{with imaging}
%if %{with embree}
BuildRequires:  embree-devel
%if %{with openshading}
BuildRequires:  openshadinglanguage
BuildRequires:  pkgconfig(oslexec)
BuildRequires:  opensubdiv-devel
%if %{with openvdb}
BuildRequires:  openvdb-devel
BuildRequires:  pkgconfig(dri)
%if %{with jemalloc}
BuildRequires:  pkgconfig(jemalloc)
%if %{with ocio}
# usd is not yet compatible with OpenColorIO 2 so use compat package.
BuildRequires:  pkgconfig(OpenColorIO) < 2
%if %{with oiio}
BuildRequires:  pkgconfig(OpenImageIO)
BuildRequires:  cmake(OpenEXR)
BuildRequires:  cmake(Imath)
BuildRequires:  pkgconfig(Ptex)
%if %{with alembic}
BuildRequires:  cmake(Alembic)
BuildRequires:  hdf5-devel

# Header-only library: -static is for tracking per guidelines
BuildRequires:  stb_image_resize-devel
BuildRequires:  stb_image_resize-static

Requires:       %{name}-libs%{?_isa} = %{version}-%{release}
%if %{with python3}
Requires:       python3-%{name}%{?_isa} = %{version}-%{release}

# Upstream bundles
# Filed ticket to convince upstream to use system libraries
Provides:       bundled(double-conversion) = 2.0.0
Provides:       bundled(ilmbase) = 2.5.3
Provides:       bundled(lz4) = 1.9.2
Provides:       bundled(pugixml) = 1.9
Provides:       bundled(rapidjson) = 1.0.2
Provides:       bundled(SPIRV-Reflect) = 1.0
Provides:       bundled(VulkanMemoryAllocator) = 3.0.0~development
# Both of these are packaged in Fedora, but USD uses patched versions, so they
# must be bundled.
Provides:       bundled(stb_image) = 2.19
Provides:       bundled(stb_image_write) = 1.09

# This package is only available for x86_64
# Will fail to build on other architectures
ExclusiveArch:  x86_64

Universal Scene Description (USD) is a time-sampled scene
description for interchange between graphics applications.

%package        libs
Summary:        Universal Scene Description library

%description libs
Universal Scene Description (USD) is an efficient, scalable system for
authoring, reading, and streaming time-sampled scene description for
interchange between graphics applications.

%package        devel
Summary:        Development files for USD
Requires:       cmake-filesystem
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}

%description devel
This package contains the C++ header files and symbolic links to the shared
libraries for %{name}. If you would like to develop programs using %{name},
you will need to install %{name}-devel.

# For usdview
%if %{with python3}
%package -n python3-%{name}
Summary: %{summary}

BuildRequires:  desktop-file-utils
BuildRequires:  pkgconfig(python3)
BuildRequires:  pkgconfig(Qt5)
BuildRequires:  python3dist(jinja2)
BuildRequires:  python3dist(pyside2)
BuildRequires:  python3dist(pyopengl)
Requires:       font(roboto)
Requires:       font(robotoblack)
Requires:       font(robotolight)
Requires:       font(robotomono)
Requires:       python3dist(jinja2)
Requires:       python3dist(pyside2)
Requires:       python3dist(pyopengl)
%py_provides    python3-pxr

%description -n python3-%{name}
Python language bindings for the Universal Scene Description (USD) C++ API

%if %{with documentation}
%package        doc
Summary:        Documentation for usd
BuildArch:      noarch

%description doc
Documentation for the Universal Scene Description (USD) C++ API

%autosetup -p1 -n %{srcname}-%{version}

# Convert NOTICE.txt from CRNL line encoding
dos2unix NOTICE.txt

%if %{with python3}
# Fix all Python shebangs recursively in .
%py3_shebang_fix .

# Further drop shebangs line for some py files
sed -r -i '1{/^#!/d}' \
        pxr/usd/sdr/ \
        pxr/usd/usdUtils/ \

# Unbundle Google Roboto fonts
rm -rvf pxr/usdImaging/usdviewq/fonts/*
ln -s %{_datadir}/fonts/google-roboto pxr/usdImaging/usdviewq/fonts/Roboto
ln -s %{_datadir}/fonts/google-roboto-mono \

# Unbundle stb_image_resize:
ln -svf %{_includedir}/stb_image_resize.h pxr/imaging/hio/stb/

# Use c++17 standard otherwise build fails
sed -i 's|set(CMAKE_CXX_STANDARD 14)|set(CMAKE_CXX_STANDARD 17)|g' \

# Fix libdir installation
sed -i 's|lib/usd|%{_libdir}/usd|g' cmake/macros/Private.cmake
sed -i 's|"lib"|%{_libdir}|g' cmake/macros/Private.cmake
sed -i 's|plugin/usd|%{_libdir}/usd/plugin|g' \
sed -i 's|/python|/python%{python3_version}/site-packages|g' \
sed -i 's|lib/usd|%{_libdir}/usd|g' cmake/macros/Public.cmake
sed -i 's|"lib"|%{_libdir}|g' cmake/macros/Public.cmake
sed -i 's|plugin/usd|%{_libdir}/usd/plugin|g' \

# Fix cmake directory destination
sed -i 's|"${CMAKE_INSTALL_PREFIX}"|%{_libdir}/cmake/pxr|g' pxr/CMakeLists.txt

# Fix uic-qt5 use
cat > uic-wrapper <<'EOF'
exec uic-qt5 -g python "$@"
chmod +x uic-wrapper

# Fix python3 support

flags="%{optflags} -Wl,--as-needed -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1" \
# Patch2 was not good enough to get the include path for Imath everywhere it
# was needed. Add it globally.
flags="${flags} $(pkgconf --cflags Imath)"

%cmake \
     -DCMAKE_CXX_FLAGS_RELEASE="${flags}" \
     -DCMAKE_C_FLAGS_RELEASE="${flags}" \
%if %{with documentation}
     -DPXR_BUILD_TESTS=%{?with_test:ON}%{!?with_test:OFF} \
%if %{with openvdb}
     -DPXR_INSTALL_LOCATION="%{_libdir}/%{name}/plugin" \
%if %{with jemalloc}
     -DPXR_MALLOC_LIBRARY="%{_libdir}/" \
%if %{with alembic}
     -DOPENEXR_LOCATION=%{_includedir} \
%if %{with embree}
     -DEMBREE_LOCATION=%{_prefix} \
%if %{with ocio}
%if %{with oiio}
%if %{with openshading}
     -DPYTHON_EXECUTABLE=%{python3} \
%if %{with python3}
     -DPYSIDEUICBINARY:PATH=${PWD}/uic-wrapper \


# Fix python3 files installation
mkdir -p %{buildroot}%{python3_sitearch}
mv %{buildroot}%{python3_sitelib}/* %{buildroot}%{python3_sitearch}

# Install a desktop icon for usdview
desktop-file-install                                    \
--dir=%{buildroot}%{_datadir}/applications              \

# Remove arch-specific code in /usr/share
find %{buildroot}%{_datadir}/%{name}/examples -name '*.so' -print -delete

# Fix installation path for some files
mv %{buildroot}%{_prefix}/lib/python/pxr/*.* \
mv %{buildroot}%{_prefix}/lib/python/pxr/Usdviewq/* \

desktop-file-validate %{buildroot}%{_datadir}/applications/{name}.%{name}view.desktop

%doc NOTICE.txt
%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/examples/

%if %{with python3}
%files -n python3-%{name}

%files libs
%license LICENSE.txt
%doc NOTICE.txt
%exclude %{_libdir}/%{name}/%{name}/resources/codegenTemplates

%files devel

%if %{with documentation}
%files doc
%license LICENSE.txt