Merge pull request #296016 from amarshall/blender-usd

blender: enable USD support; openusd: cleanup
This commit is contained in:
Dmitry Kalinkin 2024-03-16 18:42:01 -04:00 committed by GitHub
commit 127f03b7ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 132 additions and 98 deletions

View file

@ -84,6 +84,7 @@
let
python3Packages = python310Packages;
python3 = python3Packages.python;
pyPkgsOpenusd = python3Packages.openusd.override { withOsl = false; };
libdecor' = libdecor.overrideAttrs (old: {
# Blender uses private APIs, need to patch to expose them
@ -171,6 +172,7 @@ stdenv.mkDerivation (finalAttrs: {
"-DWITH_PYTHON_INSTALL_REQUESTS=OFF"
"-DWITH_SDL=OFF"
"-DWITH_TBB=ON"
"-DWITH_USD=ON"
# Blender supplies its own FindAlembic.cmake (incompatible with the Alembic-supplied config file)
"-DALEMBIC_INCLUDE_DIR=${lib.getDev alembic}/include"
@ -237,6 +239,7 @@ stdenv.mkDerivation (finalAttrs: {
(opensubdiv.override { inherit cudaSupport; })
potrace
pugixml
pyPkgsOpenusd
python3
tbb
zlib
@ -292,6 +295,7 @@ stdenv.mkDerivation (finalAttrs: {
ps.numpy
ps.requests
ps.zstandard
pyPkgsOpenusd
];
blenderExecutable =

View file

@ -1,35 +1,43 @@
{ buildPythonPackage
, fetchFromGitHub
, lib
, writeShellScriptBin
, cmake
, doxygen
, draco
, graphviz-nox
, ninja
, setuptools
, pyqt6
, pyopengl
, jinja2
, pyside6
, boost
, numpy
, git
, tbb
, opensubdiv
, openimageio
, opencolorio
, osl
, ptex
, embree
, alembic
, imath
, flex
, bison
, qt6
, python
, darwin
{
alembic,
bison,
boost,
buildPythonPackage,
cmake,
darwin,
doxygen,
draco,
embree,
fetchFromGitHub,
flex,
git,
graphviz-nox,
imath,
jinja2,
lib,
libGL,
libX11,
ninja,
numpy,
opencolorio,
openimageio,
opensubdiv,
osl,
ptex,
pyopengl,
pyqt6,
pyside6,
python,
qt6,
setuptools,
tbb,
withDocs ? false,
withOsl ? true,
withTools ? false,
withUsdView ? false,
writeShellScriptBin,
}:
let
# Matches the pyside6-uic implementation
# https://code.qt.io/cgit/pyside/pyside-setup.git/tree/sources/pyside-tools/pyside_tool.py?id=e501cad66146a49c7a259579c7bb94bc93a67a08#n82
@ -37,9 +45,11 @@ let
exec ${qt6.qtbase}/libexec/uic -g python "$@"
'';
in
buildPythonPackage rec {
pname = "OpenUSD";
version = "23.11";
src = fetchFromGitHub {
owner = "PixarAnimationStudios";
repo = pname;
@ -47,85 +57,100 @@ buildPythonPackage rec {
hash = "sha256-5zQrfB14kXs75WbL3s4eyhxELglhLNxU2L2aVXiyVjg=";
};
stdenv = if python.stdenv.isDarwin then
darwin.apple_sdk_11_0.stdenv
else
python.stdenv;
stdenv = if python.stdenv.isDarwin then darwin.apple_sdk_11_0.stdenv else python.stdenv;
outputs = ["out" "doc"];
outputs = [ "out" ] ++ lib.optional withDocs "doc";
format = "other";
propagatedBuildInputs = [
setuptools
pyqt6
pyopengl
jinja2
pyside6
pyside-tools-uic
boost
numpy
];
cmakeFlags = [
"-DPXR_BUILD_EXAMPLES=OFF"
"-DPXR_BUILD_TUTORIALS=OFF"
"-DPXR_BUILD_USD_TOOLS=ON"
"-DPXR_BUILD_IMAGING=ON"
"-DPXR_BUILD_USD_IMAGING=ON"
"-DPXR_BUILD_USDVIEW=ON"
"-DPXR_BUILD_DOCUMENTATION=ON"
"-DPXR_BUILD_PYTHON_DOCUMENTATION=ON"
"-DPXR_BUILD_EMBREE_PLUGIN=ON"
"-DPXR_BUILD_ALEMBIC_PLUGIN=ON"
"-DPXR_BUILD_DRACO_PLUGIN=ON"
"-DPXR_BUILD_EMBREE_PLUGIN=ON"
"-DPXR_BUILD_EXAMPLES=OFF"
"-DPXR_BUILD_IMAGING=ON"
"-DPXR_BUILD_MONOLITHIC=ON" # Seems to be commonly linked to monolithically
(lib.cmakeBool "PXR_ENABLE_OSL_SUPPORT" (!stdenv.isDarwin))
"-DPXR_BUILD_TESTS=OFF"
"-DPXR_BUILD_TUTORIALS=OFF"
"-DPXR_BUILD_USD_IMAGING=ON"
(lib.cmakeBool "PXR_BUILD_DOCUMENTATION" withDocs)
(lib.cmakeBool "PXR_BUILD_PYTHON_DOCUMENTATION" withDocs)
(lib.cmakeBool "PXR_BUILD_USDVIEW" withUsdView)
(lib.cmakeBool "PXR_BUILD_USD_TOOLS" withTools)
(lib.cmakeBool "PXR_ENABLE_OSL_SUPPORT" (!stdenv.isDarwin && withOsl))
];
nativeBuildInputs = [
cmake
ninja
git
qt6.wrapQtAppsHook
doxygen
graphviz-nox
nativeBuildInputs =
[
cmake
ninja
setuptools
]
++ lib.optionals withDocs [
git
graphviz-nox
doxygen
]
++ lib.optionals withUsdView [ qt6.wrapQtAppsHook ];
buildInputs =
[
alembic.dev
bison
boost
draco
embree
flex
imath
opencolorio
openimageio
opensubdiv
ptex
tbb
]
++ lib.optionals stdenv.isLinux [
libGL
libX11
]
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk_11_0.frameworks; [ Cocoa ])
++ lib.optionals withOsl [ osl ]
++ lib.optionals withUsdView [ qt6.qtbase ]
++ lib.optionals (withUsdView && stdenv.isLinux) [
qt6.qtbase
qt6.qtwayland
];
propagatedBuildInputs =
[
boost
jinja2
numpy
pyopengl
]
++ lib.optionals (withTools || withUsdView) [
pyside-tools-uic
pyside6
]
++ lib.optionals withUsdView [ pyqt6 ];
pythonImportsCheck = [
"pxr"
"pxr.Usd"
];
buildInputs = [
tbb
opensubdiv
openimageio
opencolorio
osl
ptex
embree
alembic.dev
imath
flex
bison
boost
draco
qt6.qtbase
]
++ lib.optionals stdenv.isLinux [ qt6.qtwayland ]
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk_11_0.frameworks; [
Cocoa
])
;
pythonImportsCheck = [ "pxr" "pxr.Usd" ];
postInstall = ''
# Make python lib properly accessible
target_dir=$out/${python.sitePackages}
mkdir -p $(dirname $target_dir)
mv $out/lib/python $target_dir
mv $out/docs $doc
rm $out/share -r # only examples
rm $out/tests -r
'';
postInstall =
''
# Make python lib properly accessible
target_dir=$out/${python.sitePackages}
mkdir -p $(dirname $target_dir)
mv $out/lib/python $target_dir
''
+ lib.optionalString withDocs ''
mv $out/docs $doc
''
+ ''
rm $out/share -r # only examples
'';
meta = {
description = "Universal Scene Description";

View file

@ -2001,6 +2001,11 @@ with pkgs;
openbugs = pkgsi686Linux.callPackage ../applications/science/machine-learning/openbugs { };
openusd = python3Packages.openusd.override {
withTools = true;
withUsdView = true;
};
osquery = callPackage ../tools/system/osquery { };
paperview = callPackage ../tools/X11/paperview { };