From 6a8ff011374470614830d195c666b8e6d2ec4bd8 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 28 Feb 2024 20:39:52 -0500 Subject: [PATCH 1/5] pythonPackages.openusd: formatting RFC 116 style formatting (using nixfmt-rfc-style), plus alphabetize lists. --- .../python-modules/openusd/default.nix | 168 +++++++++--------- 1 file changed, 87 insertions(+), 81 deletions(-) diff --git a/pkgs/development/python-modules/openusd/default.nix b/pkgs/development/python-modules/openusd/default.nix index 590bae1823c9..aaa1ad6411a7 100644 --- a/pkgs/development/python-modules/openusd/default.nix +++ b/pkgs/development/python-modules/openusd/default.nix @@ -1,35 +1,37 @@ -{ 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, + ninja, + numpy, + opencolorio, + openimageio, + opensubdiv, + osl, + ptex, + pyopengl, + pyqt6, + pyside6, + python, + qt6, + setuptools, + tbb, + 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 +39,11 @@ let exec ${qt6.qtbase}/libexec/uic -g python "$@" ''; in + buildPythonPackage rec { pname = "OpenUSD"; version = "23.11"; + src = fetchFromGitHub { owner = "PixarAnimationStudios"; repo = pname; @@ -47,73 +51,75 @@ 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" + "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_DOCUMENTATION=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 + "-DPXR_BUILD_PYTHON_DOCUMENTATION=ON" + "-DPXR_BUILD_TUTORIALS=OFF" + "-DPXR_BUILD_USDVIEW=ON" + "-DPXR_BUILD_USD_IMAGING=ON" + "-DPXR_BUILD_USD_TOOLS=ON" (lib.cmakeBool "PXR_ENABLE_OSL_SUPPORT" (!stdenv.isDarwin)) ]; nativeBuildInputs = [ cmake - ninja - git - qt6.wrapQtAppsHook doxygen + git graphviz-nox + ninja + qt6.wrapQtAppsHook ]; - 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" ]; + buildInputs = + [ + alembic.dev + bison + boost + draco + embree + flex + imath + opencolorio + openimageio + opensubdiv + osl + ptex + qt6.qtbase + tbb + ] + ++ lib.optionals stdenv.isLinux [ qt6.qtwayland ] + ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk_11_0.frameworks; [ Cocoa ]); + + propagatedBuildInputs = [ + boost + jinja2 + numpy + pyopengl + pyqt6 + pyside-tools-uic + pyside6 + setuptools + ]; + + pythonImportsCheck = [ + "pxr" + "pxr.Usd" + ]; postInstall = '' # Make python lib properly accessible From 1fc45775e6dcf9286d0bf63f8653234569c1cb73 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 28 Feb 2024 22:14:57 -0500 Subject: [PATCH 2/5] pythonPackages.openusd: make many extras optional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Docs are likely mostly unused, so don’t waste time and closure size building them by default - UsdView requires Qt, hugely bloating closure size and build times; enabled for now - Tools are CLI things not needed for lib usage; leave enabled for now - Skip building tests since they’re not being run here anyway, so it just massively increases build time just for them to be thrown away libGL and libX11 were implicit deps pulled in before (I guess), that now need to be explicit. --- .../python-modules/openusd/default.nix | 103 +++++++++++------- 1 file changed, 61 insertions(+), 42 deletions(-) diff --git a/pkgs/development/python-modules/openusd/default.nix b/pkgs/development/python-modules/openusd/default.nix index aaa1ad6411a7..c8c6590f4098 100644 --- a/pkgs/development/python-modules/openusd/default.nix +++ b/pkgs/development/python-modules/openusd/default.nix @@ -15,6 +15,8 @@ imath, jinja2, lib, + libGL, + libX11, ninja, numpy, opencolorio, @@ -29,6 +31,10 @@ qt6, setuptools, tbb, + withDocs ? false, + withOsl ? true, + withTools ? true, + withUsdView ? true, writeShellScriptBin, }: @@ -53,37 +59,38 @@ buildPythonPackage rec { 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"; cmakeFlags = [ "-DPXR_BUILD_ALEMBIC_PLUGIN=ON" - "-DPXR_BUILD_DOCUMENTATION=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 - "-DPXR_BUILD_PYTHON_DOCUMENTATION=ON" + "-DPXR_BUILD_TESTS=OFF" "-DPXR_BUILD_TUTORIALS=OFF" - "-DPXR_BUILD_USDVIEW=ON" "-DPXR_BUILD_USD_IMAGING=ON" - "-DPXR_BUILD_USD_TOOLS=ON" - (lib.cmakeBool "PXR_ENABLE_OSL_SUPPORT" (!stdenv.isDarwin)) + (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 - doxygen - git - graphviz-nox - ninja - qt6.wrapQtAppsHook - ]; + nativeBuildInputs = + [ + cmake + ninja + ] + ++ lib.optionals withDocs [ + git + graphviz-nox + doxygen + ] + ++ lib.optionals withUsdView [ qt6.wrapQtAppsHook ]; buildInputs = [ @@ -97,41 +104,53 @@ buildPythonPackage rec { opencolorio openimageio opensubdiv - osl ptex - qt6.qtbase tbb ] - ++ lib.optionals stdenv.isLinux [ qt6.qtwayland ] - ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk_11_0.frameworks; [ Cocoa ]); + ++ 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 - pyqt6 - pyside-tools-uic - pyside6 - setuptools - ]; + propagatedBuildInputs = + [ + boost + jinja2 + numpy + pyopengl + setuptools + ] + ++ lib.optionals (withTools || withUsdView) [ + pyside-tools-uic + pyside6 + ] + ++ lib.optionals withUsdView [ pyqt6 ]; 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"; From 35b335fe0773bdcfcc2781f3aa7de4481ae91e12 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 12 Mar 2024 19:22:29 -0400 Subject: [PATCH 3/5] python3Packages.openusd: setuptools is only needed for build --- pkgs/development/python-modules/openusd/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/openusd/default.nix b/pkgs/development/python-modules/openusd/default.nix index c8c6590f4098..b2bd04cb910f 100644 --- a/pkgs/development/python-modules/openusd/default.nix +++ b/pkgs/development/python-modules/openusd/default.nix @@ -84,6 +84,7 @@ buildPythonPackage rec { [ cmake ninja + setuptools ] ++ lib.optionals withDocs [ git @@ -125,7 +126,6 @@ buildPythonPackage rec { jinja2 numpy pyopengl - setuptools ] ++ lib.optionals (withTools || withUsdView) [ pyside-tools-uic From 108ce1896eabd6526bae91d3fcc5806e67cf812e Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 6 Mar 2024 18:17:53 -0500 Subject: [PATCH 4/5] openusd: init as python3Packages.openusd but with executables Disable building these executables when obtaining via python3*Packages, as most likely one is using that for the libraries instead, massively reducing build times and closure size for such use cases. --- pkgs/development/python-modules/openusd/default.nix | 4 ++-- pkgs/top-level/all-packages.nix | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/openusd/default.nix b/pkgs/development/python-modules/openusd/default.nix index b2bd04cb910f..f10ef51b99d8 100644 --- a/pkgs/development/python-modules/openusd/default.nix +++ b/pkgs/development/python-modules/openusd/default.nix @@ -33,8 +33,8 @@ tbb, withDocs ? false, withOsl ? true, - withTools ? true, - withUsdView ? true, + withTools ? false, + withUsdView ? false, writeShellScriptBin, }: diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7ed2913b7680..0de9fa755d4e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { }; From 5050e363760465e6e30f2e6f2e26c3c2f9678bde Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 28 Feb 2024 18:59:50 -0500 Subject: [PATCH 5/5] blender: build with USD support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We build openusd without OSL support as we don’t build Blender with OSL support normally, and so seems unnecessary and adds significantly to the closure size due to (as noted in Blender drv comments) the inclusion of LLVM. --- pkgs/applications/misc/blender/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index ebbc6cc84fef..b7f025b7eb50 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -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 @@ -166,6 +167,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" @@ -232,6 +234,7 @@ stdenv.mkDerivation (finalAttrs: { (opensubdiv.override { inherit cudaSupport; }) potrace pugixml + pyPkgsOpenusd python3 tbb zlib @@ -287,6 +290,7 @@ stdenv.mkDerivation (finalAttrs: { ps.numpy ps.requests ps.zstandard + pyPkgsOpenusd ]; blenderExecutable =